home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / bindings / modeori-fun / functions < prev    next >
Encoding:
Text File  |  1996-09-27  |  110.8 KB  |  4,574 lines

  1. ;OCL{{{}}}
  2. ;OCL{{{  user macros
  3. ( defusermacros 10 )
  4. ;OCL{{{  user-macro-x
  5. ( defmac user-macro-0 ( execute-number-macro 1 ) )
  6. ( defmac user-macro-1 ( execute-number-macro 2 ) )
  7. ( defmac user-macro-2 ( execute-number-macro 3 ) )
  8. ( defmac user-macro-3 ( execute-number-macro 4 ) )
  9. ( defmac user-macro-4 ( execute-number-macro 5 ) )
  10. ( defmac user-macro-5 ( execute-number-macro 6 ) )
  11. ( defmac user-macro-6 ( execute-number-macro 7 ) )
  12. ( defmac user-macro-7 ( execute-number-macro 8 ) )
  13. ( defmac user-macro-8 ( execute-number-macro 9 ) )
  14. ( defmac user-macro-9 ( execute-number-macro 10 ) )
  15. ;OCL}}}
  16. ;OCL{{{  def-user-macro
  17. ( defvar ( u-m-no ) )
  18. ( deffun def-user-macro
  19.    ( if not(in-prompt)
  20.       ( para
  21.         prompt-counter u-m-no ( "user-macro "  "? "  )
  22.         if not(and(>(-(u-m-no 9) 0) <=(u-m-no 0)))
  23.          ( set u-m-no +(u-m-no 1)
  24.            save-keyboard-macro counter u-m-no newline-and-indent
  25.          )
  26.         fi
  27.         edit
  28.       )
  29.      fi
  30.    )
  31. )
  32. ( undeclare ( u-m-no ) )
  33. ;OCL}}}
  34. ;OCL}}}
  35. ;OCL{{{  vars
  36. ( defvar
  37.    ( buffer-moving    ; buffer-move-mode is activ
  38.      moving           ; move-mode is activ
  39.      stepping         ; line-movement display or file-based?
  40.      status-line      ; display status-line in edit-mode?
  41.      buff-saving      ; is buffer-save-mode activ?
  42.      irline           ; cursor level for indent region
  43.      command          ; left move-mode after succesful command?
  44.      startup          ; 1, if startup-code was executed
  45.      highlight-off    ; no highlighted display during creat-fold/move-mode
  46.      full-shifting    ; is full-shift-mode active?
  47.      prompting        ; have libraries to call prompt-macros?
  48.      cmd-in           ; variable for reading command in menus ..
  49.      extended-version ; use the extended-,not-extended- or raw-mode?
  50.      no-auto-change   ; do not change the file in read-newfile-macro
  51.      @if-using ( SHELL-MODE )
  52.         shell-mode-active
  53.                       ; switch to ModeOriShell at quit of editing
  54.      @fi
  55.      @if-using ( SUNEDT )
  56.         EDT-used      ; TERM on SUNEDT or ORIGAMITERM on SUNEDT
  57.         EDT-move-back ; edt simulation moves back
  58.      @fi
  59.    )
  60. )
  61. ( history make-cmd-hist )
  62. ( history mail-cmd-hist )
  63. ( history string-buffer )
  64. @if-using ( SHELL-MODE )
  65.    ( history I-edit-cmd )
  66.    ( history I-nn-cmd )
  67. @fi
  68. ;OCL}}}
  69. ;OCL{{{  forward declarations
  70. ( forward switch-off-buffer-handling )
  71. ( forward switch-on-buffer-handling  )
  72. ( forward b-m-menu                   )
  73. ( forward change-buffer-macro-exe    )
  74. ( forward read-newfile-macro-exe     )
  75. ( forward switch-to-move-mode        )
  76. ( forward switch-to-edit-mode        )
  77. ( forward switch-status-line-on      )
  78. ( forward switch-status-line-off     )
  79. ( forward abort-hook                 )
  80. ( forward knb-macro                  )
  81. ( forward v-macro                    )
  82. ( forward begin-prompt               )
  83. ( forward end-prompt                 )
  84. ( forward set-mode-raw               )
  85. ( forward add-mode-extended          )
  86. ( forward delete-mode-extended       )
  87. @if-using ( SHELL-MODE )
  88.    @if-using (MOUSY)
  89.       ( forward ( cmd ) shell-mouse     )
  90.    @fi
  91.    ( forward add-mode-shell          )
  92.    ( forward I-startup-read          )
  93.    ( forward I-startup               )
  94.    ( forward I-key-not-bound         )
  95.    ( forward begin-shell-mode        )
  96.    ( forward end-shell-mode          )
  97.    ( forward I-view-macro            )
  98.    ( forward I-abort-hook            )
  99.    ( forward I-prompt-in             )
  100.    ( forward I-prompt-out            )
  101. @fi
  102. ;OCL}}}
  103. ;OCL{{{  declare macro-hooks
  104. ( abort-macro         abort-hook             )
  105. ( change-buffer-macro change-buffer-macro-exe)
  106. ( read-newfile-macro  read-newfile-macro-exe )
  107. ( key-not-bound-macro knb-macro              )
  108. ( view-macro          v-macro                )
  109. ( begin-prompt-macro  begin-prompt           )
  110. ( end-prompt-macro    end-prompt             )
  111. ;OCL}}}
  112. ;OCL{{{  character-set handling
  113. @use ( language-ocl )
  114. @lib userlang
  115. ;OCL{{{  variables
  116. ( defvar ( char-set-changed ) )
  117. ;OCL}}}
  118. ;OCL{{{  touch-char-sets
  119. ( defmac touch-char-sets ( set char-set-changed true ) )
  120. ;OCL}}}
  121. ;OCL{{{  setup-char-sets
  122. ( deffun setup-char-sets
  123.    ( if char-set-changed
  124.       ( case
  125.          ;OCL{{{  programming
  126.          ( or
  127.             ( test-language C
  128.               test-language Pascal
  129.               test-language Occam
  130.               test-language Inmos
  131.               test-language Script
  132.             )
  133.             ( defset word-char word-char-coding )
  134.          )
  135.          ;OCL}}}
  136.          ;OCL{{{  ocl
  137.          ( eval ( test-language-ocl )
  138.             ( defset word-char word-char-ocl )
  139.          )
  140.          ;OCL}}}
  141.         default
  142.          ;OCL{{{  text
  143.          ( defset word-char word-char-text )
  144.          ;OCL}}}
  145.         esac
  146.         set char-set-changed false
  147.       )
  148.      fi
  149.    )
  150. )
  151. ;OCL}}}
  152. ;OCL{{{  redefine set-language and search-commands
  153. ;OCL{{{  set-language
  154. ( defmac set-language- ( set-language ) )
  155. ( undeclare ( set-language ) )
  156. ( deffun set-language ( touch-char-sets set-language- ) )
  157. ( undeclare ( set-language- ) )
  158. ;OCL}}}
  159. ;OCL{{{  search-forward
  160. ( defmac search-forward- ( search-forward ) )
  161. ( undeclare ( search-forward ) )
  162. ( deffun search-forward ( setup-char-sets search-forward- ) )
  163. ( undeclare ( search-forward- ) )
  164. ;OCL}}}
  165. ;OCL{{{  incremental-search-forward
  166. ( defmac incremental-search-forward- ( incremental-search-forward ) )
  167. ( undeclare ( incremental-search-forward ) )
  168. ( deffun incremental-search-forward ( setup-char-sets incremental-search-forward- ) )
  169. ( undeclare ( incremental-search-forward- ) )
  170. ;OCL}}}
  171. ;OCL{{{  query-replace-string
  172. ( defmac query-replace-string- ( query-replace-string ) )
  173. ( undeclare ( query-replace-string ) )
  174. ( deffun query-replace-string ( setup-char-sets query-replace-string- ) )
  175. ( undeclare ( query-replace-string- ) )
  176. ;OCL}}}
  177. ;OCL{{{  replace-string
  178. ( defmac replace-string- ( replace-string ) )
  179. ( undeclare ( replace-string ) )
  180. ( deffun replace-string ( setup-char-sets replace-string- ) )
  181. ( undeclare ( replace-string- ) )
  182. ;OCL}}}
  183. ;OCL}}}
  184. ;OCL{{{  undeclares
  185. ( undeclare ( char-set-changed ) )
  186. ;OCL}}}
  187. ;OCL}}}
  188. ;OCL{{{  auto-save
  189. ( forward mori-dump-buffers-to-file )
  190. ;OCL{{{  variables
  191. ( defvar ( a-s-delayed a-s-delaying a-s-x a-s-done ) )
  192. ;OCL}}}
  193. ;OCL{{{  auto-save-hook
  194. @lib hide-buffer
  195. ( forward e-m-save-file )
  196. ( deffun auto-save-hook
  197.    ( @if-using ( SHELL-MODE )
  198.         if shell-mode-active
  199.          ( return-from-macro )
  200.         fi
  201.      @fi
  202.      set a-s-delayed a-s-delaying
  203.      if not(a-s-delayed)
  204.       ( set a-s-x current-buffer-number
  205.         ;OCL{{{  save all buffers
  206.         screen-off
  207.         push-buffer-layout
  208.         ;OCL{{{  loop
  209.         local
  210.          ( a-s-x )
  211.          (
  212.            set a-s-done 0
  213.            set a-s-x 1
  214.            while <=(a-s-x used-buffers)
  215.             ;OCL{{{  save buffer
  216.             ( goto-buffer-number a-s-x
  217.               if test-file-changed
  218.                ( e-m-save-file
  219.                  if not(test-file-changed)
  220.                   ( set a-s-done +(a-s-done 1))
  221.                  fi
  222.                )
  223.               fi
  224.               set a-s-x +(a-s-x 1)
  225.             )
  226.             ;OCL}}}
  227.          )
  228.         ;OCL}}}
  229.         goto-buffer-number a-s-x
  230.         pop-buffer-layout
  231.         screen-on
  232.         redraw-display
  233.         ;OCL}}}
  234.         ;OCL{{{  maybe save buffers
  235.         if buff-saving ( mori-dump-buffers-to-file ) fi
  236.         ;OCL}}}
  237.         if a-s-done ( message ( "[ counter a-s-done "  "auto-saved "] ) ) fi
  238.       )
  239.      fi
  240.    )
  241. )
  242. ;OCL}}}
  243. ;OCL{{{  delay-auto-save
  244. ( defmac delay-auto-save ( set a-s-delaying +(a-s-delaying 1) ) )
  245. ;OCL}}}
  246. ;OCL{{{  flush-auto-save
  247. ( defmac flush-auto-save
  248.    ( if >(a-s-delaying 0)
  249.       ( set a-s-delaying -(a-s-delaying 1)
  250.         if a-s-delayed ( auto-save-hook ) fi
  251.       )
  252.      fi
  253.    )
  254. )
  255. ;OCL}}}
  256. ;OCL{{{  restore-auto-save
  257. ( defmac restore-auto-save
  258.    ( set a-s-delaying 0
  259.      if a-s-delayed ( auto-save-hook ) fi
  260.    )
  261. )
  262. ;OCL}}}
  263. ( autosave-macro auto-save-hook )
  264. ;OCL{{{  undelcares
  265. ( undeclare ( a-s-delayed a-s-delaying a-s-x a-s-done auto-save-hook ) )
  266. ;OCL}}}
  267. ;OCL}}}
  268. ;OCL{{{  standard macro
  269. @lib delspaces
  270. @lib delchar
  271. @lib overwdel
  272. @lib error
  273. @lib mt-fold
  274. @lib go-line
  275. @lib append
  276. @lib pre-char
  277. ( demand-load ( @lib noover ) )
  278. ;OCL{{{  mori-goto-matching-brace
  279. ( demand-load ( @lib go-match ) )
  280. ( defmac mori-goto-matching-brace ( goto-matching-fence ) )
  281. ;OCL}}}
  282. ;OCL{{{  word-jumps
  283. ;OCL{{{  backward-word
  284. ;OCL{{{  backward-text-word
  285. ;OCL{{{  word-line-up
  286. ( deffun word-line-up
  287.    ( if test-top ( failed ) fi
  288.      previous-line
  289.      end-of-line
  290.    )
  291. )
  292. ;OCL}}}
  293.  
  294. ( defmac backward-text-word
  295.    (
  296.      ;OCL{{{  one step left
  297.      if test-begin-line
  298.        ( word-line-up )
  299.      else
  300.        ( backward-character )
  301.      fi
  302.      ;OCL}}}
  303.      while not(test-char-set word-char)
  304.       ;OCL{{{  back or line up
  305.       ( if =(+(store-pos -1) 0)
  306.          ( word-line-up )
  307.         else
  308.          ( backward-character )
  309.         fi
  310.       )
  311.       ;OCL}}}
  312.      ;OCL{{{  start-word
  313.      while test-char-set word-char
  314.       ( if test-begin-line
  315.          ( return-from-macro )
  316.         else
  317.          ( backward-character )
  318.         fi
  319.       )
  320.      forward-character
  321.      ;OCL}}}
  322.    )
  323. )
  324. ;OCL}}}
  325.  
  326. ( deffun backward-word
  327.    ( case
  328.       ( in-prompt ( ) )
  329.      default
  330.       ( setup-char-sets
  331.         backward-text-word
  332.       )
  333.      esac
  334.    )
  335. )
  336. ;OCL}}}
  337. ;OCL{{{  forward-word
  338. ;OCL{{{  forward-text-word
  339. ;OCL{{{  word-line-down          go to beginning of next line for word
  340. ( deffun word-line-down
  341.    ( if test-bottom ( failed ) fi
  342.      next-line
  343.      beginning-of-line
  344.    )
  345. )
  346. ;OCL}}}
  347.  
  348. ( defmac forward-text-word
  349.    (
  350.      ;OCL{{{  end word or next-line
  351.      if test-end-line
  352.        ( word-line-down )
  353.      else
  354.        ( while test-char-set word-char ( forward-character ) )
  355.      fi
  356.      ;OCL}}}
  357.      while not(test-char-set word-char)
  358.       ;OCL{{{  right or down
  359.       ( if test-end-line ( word-line-down ) else ( forward-character ) fi )
  360.       ;OCL}}}
  361.    )
  362. )
  363. ;OCL}}}
  364.  
  365. ( deffun forward-word
  366.    ( case
  367.       ( in-prompt ( ) )
  368.      default
  369.       ( setup-char-sets
  370.         forward-text-word
  371.       )
  372.      esac
  373.    )
  374. )
  375. ;OCL}}}
  376. ;OCL}}}
  377. ;OCL{{{  mode-center
  378. ( defvar ( centering ) )
  379. ;OCL{{{  add-mode-center
  380. ( deffun add-mode-center
  381.    ( set centering true
  382.      set-cursor-line div(screen-height 2)
  383.    )
  384. )
  385. ;OCL}}}
  386. ;OCL{{{  delete-mode-center
  387. ( deffun delete-mode-center ( set centering false ) )
  388. ;OCL}}}
  389. ;OCL{{{  do-mode-center
  390. ( deffun do-mode-center
  391.    ( if centering
  392.       ( set-cursor-line div(screen-height 2) )
  393.      fi
  394.    )
  395. )
  396. ;OCL}}}
  397. ;OCL}}}
  398. ;OCL{{{  mori-next-line
  399. ( deffun mori-next-line
  400.    ( if and(not(in-prompt) test-fold-line stepping)
  401.       ( open-fold )
  402.      fi
  403.      next-line
  404.      do-mode-center
  405.    )
  406. )
  407. ;OCL}}}
  408. ;OCL{{{  mori-previous-line
  409. ( deffun mori-previous-line
  410.    ( previous-line
  411.      while and(not(in-prompt) test-fold-line stepping)
  412.       ( open-fold mtool-bot )
  413.      do-mode-center
  414.    )
  415. )
  416. ;OCL}}}
  417. ;OCL{{{  mori-open-fold
  418. ( defvar ( op-f-k ) )
  419. ( deffun mori-open-fold
  420.    ( case
  421.       ;OCL{{{  not directly after open -> open
  422.       ( <>(key-count op-f-k) ( open-fold set op-f-k +(key-count 1) ) )
  423.       ;OCL}}}
  424.       ;OCL{{{  moving -> nop
  425.       ( moving () )
  426.       ;OCL}}}
  427.       ;OCL{{{  filed -> open failed -> enter
  428.       ( test-filed ( enter-fold ) )
  429.       ;OCL}}}
  430.       ;OCL{{{  begin-fold -> close and enter
  431.       ( test-begin-fold ( close-fold enter-fold previous-line ) )
  432.       ;OCL}}}
  433.      esac
  434.    )
  435. )
  436. ( undeclare ( op-f-k ) )
  437. ;OCL}}}
  438. ;OCL{{{  mori-close-fold
  439. ( defvar ( cl-f-k ) )
  440. ( deffun mori-close-fold
  441.    ( case
  442.       ;OCL{{{  direct after failed close -> exit
  443.       ( <>(key-count cl-f-k)
  444.          ( if last-message M_USE_EXIT () fi
  445.            if last-message M_TOP () fi
  446.            close-fold
  447.            if or(last-message M_TOP last-message M_USE_EXIT)
  448.             ( set cl-f-k +(key-count 1)
  449.               bell visible-bell
  450.               show-cursor 5
  451.             )
  452.            fi
  453.          )
  454.       )
  455.       ;OCL}}}
  456.       ;OCL{{{  moving -> nop
  457.       ( moving () )
  458.       ;OCL}}}
  459.      default
  460.       ;OCL{{{  exit and open, if possible
  461.       ( exit-fold
  462.         if not(test-filed) ( open-fold ) fi
  463.       )
  464.       ;OCL}}}
  465.      esac
  466.    )
  467. )
  468. ( undeclare ( cl-f-k ) )
  469. ;OCL}}}
  470. ;OCL{{{  page-moves
  471. ( defvar ( np-level np-height ) )
  472. ;OCL{{{  next-page
  473. ( defmac next-page-def ( next-page ) )
  474. ( undeclare ( next-page ) )
  475. ( deffun next-page
  476.    ( if in-prompt
  477.       ( next-page-def )
  478.      else
  479.       (
  480.         ;OCL{{{  get number of skip-lines
  481.         set-counter np-level cursor-level
  482.         set-counter np-height -( screen-height 1 )
  483.         ;OCL}}}
  484.         ;OCL{{{  skip and set cursor
  485.         screen-off
  486.         while >(np-height 0)
  487.          ;OCL{{{  skip one line
  488.          ( next-line
  489.            if and(stepping test-fold-line)
  490.             ;OCL{{{  open and stop the loop
  491.             ( open-fold
  492.               set-counter np-height 0
  493.             )
  494.             ;OCL}}}
  495.            else
  496.             ;OCL{{{  decrement the number of skip-lines
  497.             ( set-counter np-height -(np-height 1) )
  498.             ;OCL}}}
  499.            fi
  500.          )
  501.          ;OCL}}}
  502.         screen-on
  503.         set-cursor-line np-level
  504.         ;OCL}}}
  505.       )
  506.      fi
  507.    )
  508. )
  509. ( undeclare ( next-page-def ) )
  510. ;OCL}}}
  511. ;OCL{{{  previous-page
  512. ( defmac previous-page-def ( previous-page ) )
  513. ( undeclare ( previous-page ) )
  514. ( deffun previous-page
  515.    ( if in-prompt
  516.       ( previous-page-def )
  517.      else
  518.       (
  519.         ;OCL{{{  get number of skip-lines
  520.         set-counter np-level cursor-level
  521.         set-counter np-height -( screen-height 1 )
  522.         ;OCL}}}
  523.         ;OCL{{{  skip and set cursor
  524.         screen-off
  525.         while >(np-height 0)
  526.          ;OCL{{{  skip one line
  527.          ( previous-line
  528.            if and(stepping test-fold-line)
  529.             ;OCL{{{  open and stop the loop
  530.             ( open-fold
  531.               mtool-bot
  532.               set-counter np-height 0
  533.             )
  534.             ;OCL}}}
  535.            else
  536.             ;OCL{{{  decrement the number of skip-lines
  537.             ( set-counter np-height -(np-height 1) )
  538.             ;OCL}}}
  539.            fi
  540.          )
  541.          ;OCL}}}
  542.         screen-on
  543.         set-cursor-line np-level
  544.         ;OCL}}}
  545.       )
  546.      fi
  547.    )
  548. )
  549. ( undeclare ( previous-page-def ) )
  550. ;OCL}}}
  551. ( undeclare ( np-level np-height ) )
  552. ;OCL}}}
  553. ;OCL{{{  add-mode-file-based
  554. ( deffun add-mode-file-based ( set-counter stepping true set-user-mode STEP ) )
  555. ;OCL}}}
  556. ;OCL{{{  delete-mode-file-based
  557. ( deffun delete-mode-file-based ( set-counter stepping false reset-user-mode STEP ) )
  558. ;OCL}}}
  559. ;OCL{{{  marks
  560. ;OCL{{{  define the needed vars
  561. ( defvar
  562.    ( mark-line mark-file
  563.      mark-line-0 mark-file-0
  564.      mark-line-1 mark-file-1
  565.      mark-line-2 mark-file-2
  566.      mark-line-3 mark-file-3
  567.      mark-line-4 mark-file-4
  568.      mark-line-5 mark-file-5
  569.      mark-line-6 mark-file-6
  570.      mark-line-7 mark-file-7
  571.      mark-line-8 mark-file-8
  572.      mark-line-9 mark-file-9
  573.      push-mark
  574.    )
  575. )
  576. ;OCL}}}
  577. ;OCL{{{  go-last-mark
  578. ( deffun go-last-mark
  579.    (
  580.      ;OCL{{{  maybe change the file
  581.      if <>(-(file-number mark-file) 0)
  582.       (
  583.         ;OCL{{{  moving cannot change files
  584.         if moving
  585.          ( switch-to-edit-mode
  586.            bell
  587.            visible-bell
  588.            message-exit ( "[ "no "  "filechange "  "in "  "move-mode! "] )
  589.          )
  590.         fi
  591.         ;OCL}}}
  592.         ;OCL{{{  change the file
  593.         if last-message M_FILEPO () fi
  594.         if >(push-mark 0) ( enter-list-file ) else ( read-list-file ) fi
  595.            if not(last-message M_FILEPO) ( insert-ascii I_YES newline-and-indent ) fi
  596.            counter mark-file
  597.            newline-and-indent
  598.         ;OCL}}}
  599.       )
  600.      fi
  601.      ;OCL}}}
  602.      goto-line-counter mark-line
  603.    )
  604. )
  605. ;OCL}}}
  606. ;OCL{{{  0
  607. ;OCL{{{  set-mark-0
  608. ( deffun set-mark-0
  609.    ( set-counter mark-file-0 file-number
  610.      set-counter mark-line-0 store-line
  611.    )
  612. )
  613. ;OCL}}}
  614. ;OCL{{{  go-mark-0
  615. ( deffun go-mark-0
  616.    ( set-counter mark-file mark-file-0
  617.      set-counter mark-line mark-line-0
  618.      set-counter push-mark 0
  619.      go-last-mark
  620.    )
  621. )
  622. ;OCL}}}
  623. ;OCL{{{  push-mark-0
  624. ( deffun push-mark-0
  625.    ( set-counter mark-file mark-file-0
  626.      set-counter mark-line mark-line-0
  627.      set-counter push-mark 1
  628.      go-last-mark
  629.    )
  630. )
  631. ;OCL}}}
  632. ;OCL{{{  swap-mark-0
  633. ( deffun swap-mark-0
  634.    ( set-counter mark-file mark-file-0
  635.      set-counter mark-line mark-line-0
  636.      set-counter push-mark 1
  637.      set-mark-0
  638.      go-last-mark
  639.    )
  640. )
  641. ;OCL}}}
  642. ;OCL}}}
  643. ;OCL{{{  1
  644. ;OCL{{{  set-mark-1
  645. ( deffun set-mark-1
  646.    ( set-counter mark-file-1 file-number
  647.      set-counter mark-line-1 store-line
  648.    )
  649. )
  650. ;OCL}}}
  651. ;OCL{{{  go-mark-1
  652. ( deffun go-mark-1
  653.    ( set-counter mark-file mark-file-1
  654.      set-counter mark-line mark-line-1
  655.      set-counter push-mark 0
  656.      go-last-mark
  657.    )
  658. )
  659. ;OCL}}}
  660. ;OCL{{{  push-mark-1
  661. ( deffun push-mark-1
  662.    ( set-counter mark-file mark-file-1
  663.      set-counter mark-line mark-line-1
  664.      set-counter push-mark 1
  665.      go-last-mark
  666.    )
  667. )
  668. ;OCL}}}
  669. ;OCL{{{  swap-mark-1
  670. ( deffun swap-mark-1
  671.    ( set-counter mark-file mark-file-1
  672.      set-counter mark-line mark-line-1
  673.      set-counter push-mark 1
  674.      set-mark-1
  675.      go-last-mark
  676.    )
  677. )
  678. ;OCL}}}
  679. ;OCL}}}
  680. ;OCL{{{  2
  681. ;OCL{{{  set-mark-2
  682. ( deffun set-mark-2
  683.    ( set-counter mark-file-2 file-number
  684.      set-counter mark-line-2 store-line
  685.    )
  686. )
  687. ;OCL}}}
  688. ;OCL{{{  go-mark-2
  689. ( deffun go-mark-2
  690.    ( set-counter mark-file mark-file-2
  691.      set-counter mark-line mark-line-2
  692.      set-counter push-mark 0
  693.      go-last-mark
  694.    )
  695. )
  696. ;OCL}}}
  697. ;OCL{{{  push-mark-2
  698. ( deffun push-mark-2
  699.    ( set-counter mark-file mark-file-2
  700.      set-counter mark-line mark-line-2
  701.      set-counter push-mark 1
  702.      go-last-mark
  703.    )
  704. )
  705. ;OCL}}}
  706. ;OCL{{{  swap-mark-2
  707. ( deffun swap-mark-2
  708.    ( set-counter mark-file mark-file-2
  709.      set-counter mark-line mark-line-2
  710.      set-counter push-mark 1
  711.      set-mark-2
  712.      go-last-mark
  713.    )
  714. )
  715. ;OCL}}}
  716. ;OCL}}}
  717. ;OCL{{{  3
  718. ;OCL{{{  set-mark-3
  719. ( deffun set-mark-3
  720.    ( set-counter mark-file-3 file-number
  721.      set-counter mark-line-3 store-line
  722.    )
  723. )
  724. ;OCL}}}
  725. ;OCL{{{  go-mark-3
  726. ( deffun go-mark-3
  727.    ( set-counter mark-file mark-file-3
  728.      set-counter mark-line mark-line-3
  729.      set-counter push-mark 0
  730.      go-last-mark
  731.    )
  732. )
  733. ;OCL}}}
  734. ;OCL{{{  push-mark-3
  735. ( deffun push-mark-3
  736.    ( set-counter mark-file mark-file-3
  737.      set-counter mark-line mark-line-3
  738.      set-counter push-mark 1
  739.      go-last-mark
  740.    )
  741. )
  742. ;OCL}}}
  743. ;OCL{{{  swap-mark-3
  744. ( deffun swap-mark-3
  745.    ( set-counter mark-file mark-file-3
  746.      set-counter mark-line mark-line-3
  747.      set-counter push-mark 1
  748.      set-mark-3
  749.      go-last-mark
  750.    )
  751. )
  752. ;OCL}}}
  753. ;OCL}}}
  754. ;OCL{{{  4
  755. ;OCL{{{  set-mark-4
  756. ( deffun set-mark-4
  757.    ( set-counter mark-file-4 file-number
  758.      set-counter mark-line-4 store-line
  759.    )
  760. )
  761. ;OCL}}}
  762. ;OCL{{{  go-mark-4
  763. ( deffun go-mark-4
  764.    ( set-counter mark-file mark-file-4
  765.      set-counter mark-line mark-line-4
  766.      set-counter push-mark 0
  767.      go-last-mark
  768.    )
  769. )
  770. ;OCL}}}
  771. ;OCL{{{  push-mark-4
  772. ( deffun push-mark-4
  773.    ( set-counter mark-file mark-file-4
  774.      set-counter mark-line mark-line-4
  775.      set-counter push-mark 1
  776.      go-last-mark
  777.    )
  778. )
  779. ;OCL}}}
  780. ;OCL{{{  swap-mark-4
  781. ( deffun swap-mark-4
  782.    ( set-counter mark-file mark-file-4
  783.      set-counter mark-line mark-line-4
  784.      set-counter push-mark 1
  785.      set-mark-4
  786.      go-last-mark
  787.    )
  788. )
  789. ;OCL}}}
  790. ;OCL}}}
  791. ;OCL{{{  5
  792. ;OCL{{{  set-mark-5
  793. ( deffun set-mark-5
  794.    ( set-counter mark-file-5 file-number
  795.      set-counter mark-line-5 store-line
  796.    )
  797. )
  798. ;OCL}}}
  799. ;OCL{{{  go-mark-5
  800. ( deffun go-mark-5
  801.    ( set-counter mark-file mark-file-5
  802.      set-counter mark-line mark-line-5
  803.      set-counter push-mark 0
  804.      go-last-mark
  805.    )
  806. )
  807. ;OCL}}}
  808. ;OCL{{{  push-mark-5
  809. ( deffun push-mark-5
  810.    ( set-counter mark-file mark-file-5
  811.      set-counter mark-line mark-line-5
  812.      set-counter push-mark 1
  813.      go-last-mark
  814.    )
  815. )
  816. ;OCL}}}
  817. ;OCL{{{  swap-mark-5
  818. ( deffun swap-mark-5
  819.    ( set-counter mark-file mark-file-5
  820.      set-counter mark-line mark-line-5
  821.      set-counter push-mark 1
  822.      set-mark-5
  823.      go-last-mark
  824.    )
  825. )
  826. ;OCL}}}
  827. ;OCL}}}
  828. ;OCL{{{  6
  829. ;OCL{{{  set-mark-6
  830. ( deffun set-mark-6
  831.    ( set-counter mark-file-6 file-number
  832.      set-counter mark-line-6 store-line
  833.    )
  834. )
  835. ;OCL}}}
  836. ;OCL{{{  go-mark-6
  837. ( deffun go-mark-6
  838.    ( set-counter mark-file mark-file-6
  839.      set-counter mark-line mark-line-6
  840.      set-counter push-mark 0
  841.      go-last-mark
  842.    )
  843. )
  844. ;OCL}}}
  845. ;OCL{{{  push-mark-6
  846. ( deffun push-mark-6
  847.    ( set-counter mark-file mark-file-6
  848.      set-counter mark-line mark-line-6
  849.      set-counter push-mark 1
  850.      go-last-mark
  851.    )
  852. )
  853. ;OCL}}}
  854. ;OCL{{{  swap-mark-6
  855. ( deffun swap-mark-6
  856.    ( set-counter mark-file mark-file-6
  857.      set-counter mark-line mark-line-6
  858.      set-counter push-mark 1
  859.      set-mark-6
  860.      go-last-mark
  861.    )
  862. )
  863. ;OCL}}}
  864. ;OCL}}}
  865. ;OCL{{{  7
  866. ;OCL{{{  set-mark-7
  867. ( deffun set-mark-7
  868.    ( set-counter mark-file-7 file-number
  869.      set-counter mark-line-7 store-line
  870.    )
  871. )
  872. ;OCL}}}
  873. ;OCL{{{  go-mark-7
  874. ( deffun go-mark-7
  875.    ( set-counter mark-file mark-file-7
  876.      set-counter mark-line mark-line-7
  877.      set-counter push-mark 0
  878.      go-last-mark
  879.    )
  880. )
  881. ;OCL}}}
  882. ;OCL{{{  push-mark-7
  883. ( deffun push-mark-7
  884.    ( set-counter mark-file mark-file-7
  885.      set-counter mark-line mark-line-7
  886.      set-counter push-mark 1
  887.      go-last-mark
  888.    )
  889. )
  890. ;OCL}}}
  891. ;OCL{{{  swap-mark-7
  892. ( deffun swap-mark-7
  893.    ( set-counter mark-file mark-file-7
  894.      set-counter mark-line mark-line-7
  895.      set-counter push-mark 1
  896.      set-mark-7
  897.      go-last-mark
  898.    )
  899. )
  900. ;OCL}}}
  901. ;OCL}}}
  902. ;OCL{{{  8
  903. ;OCL{{{  set-mark-8
  904. ( deffun set-mark-8
  905.    ( set-counter mark-file-8 file-number
  906.      set-counter mark-line-8 store-line
  907.    )
  908. )
  909. ;OCL}}}
  910. ;OCL{{{  go-mark-8
  911. ( deffun go-mark-8
  912.    ( set-counter mark-file mark-file-8
  913.      set-counter mark-line mark-line-8
  914.      set-counter push-mark 0
  915.      go-last-mark
  916.    )
  917. )
  918. ;OCL}}}
  919. ;OCL{{{  push-mark-8
  920. ( deffun push-mark-8
  921.    ( set-counter mark-file mark-file-8
  922.      set-counter mark-line mark-line-8
  923.      set-counter push-mark 1
  924.      go-last-mark
  925.    )
  926. )
  927. ;OCL}}}
  928. ;OCL{{{  swap-mark-8
  929. ( deffun swap-mark-8
  930.    ( set-counter mark-file mark-file-8
  931.      set-counter mark-line mark-line-8
  932.      set-counter push-mark 1
  933.      set-mark-8
  934.      go-last-mark
  935.    )
  936. )
  937. ;OCL}}}
  938. ;OCL}}}
  939. ;OCL{{{  9
  940. ;OCL{{{  set-mark-9
  941. ( deffun set-mark-9
  942.    ( set-counter mark-file-9 file-number
  943.      set-counter mark-line-9 store-line
  944.    )
  945. )
  946. ;OCL}}}
  947. ;OCL{{{  go-mark-9
  948. ( deffun go-mark-9
  949.    ( set-counter mark-file mark-file-9
  950.      set-counter mark-line mark-line-9
  951.      set-counter push-mark 0
  952.      go-last-mark
  953.    )
  954. )
  955. ;OCL}}}
  956. ;OCL{{{  push-mark-9
  957. ( deffun push-mark-9
  958.    ( set-counter mark-file mark-file-9
  959.      set-counter mark-line mark-line-9
  960.      set-counter push-mark 1
  961.      go-last-mark
  962.    )
  963. )
  964. ;OCL}}}
  965. ;OCL{{{  swap-mark-9
  966. ( deffun swap-mark-9
  967.    ( set-counter mark-file mark-file-9
  968.      set-counter mark-line mark-line-9
  969.      set-counter push-mark 1
  970.      set-mark-9
  971.      go-last-mark
  972.    )
  973. )
  974. ;OCL}}}
  975. ;OCL}}}
  976. ;OCL{{{  undefine the needed vars
  977. ( undeclare
  978.    ( mark-line mark-file
  979.      mark-line-0 mark-file-0
  980.      mark-line-1 mark-file-1
  981.      mark-line-2 mark-file-2
  982.      mark-line-3 mark-file-3
  983.      mark-line-4 mark-file-4
  984.      mark-line-5 mark-file-5
  985.      mark-line-6 mark-file-6
  986.      mark-line-7 mark-file-7
  987.      mark-line-8 mark-file-8
  988.      mark-line-9 mark-file-9
  989.      push-mark
  990.    )
  991. )
  992. ;OCL}}}
  993. ;OCL}}}
  994. ;OCL{{{  searches
  995. ;OCL{{{  mori-incremental-search-forward
  996. ( deffun mori-incremental-search-forward
  997.    ( set-mark-0
  998.      incremental-search-forward
  999.    )
  1000. )
  1001. ;OCL}}}
  1002. ;OCL{{{  mori-search-forward
  1003. ( deffun mori-search-forward
  1004.    ( set-mark-0
  1005.      search-forward
  1006.    )
  1007. )
  1008. ;OCL}}}
  1009. ;OCL{{{  mori-query-replace-string
  1010. ( deffun mori-query-replace-string
  1011.    ( set-mark-0
  1012.      query-replace-string
  1013.    )
  1014. )
  1015. ;OCL}}}
  1016. ;OCL}}}
  1017. ;OCL{{{  mouse macros
  1018. @if-using (MOUSY)
  1019.   @lib go-mouse
  1020.   ;OCL{{{  goto-window
  1021.   ( deffun goto-window
  1022.      ( if <>(mouse-buffer-number current-buffer-number)
  1023.         ( goto-buffer-number mouse-buffer-number )
  1024.        fi
  1025.      )
  1026.   )
  1027.   ;OCL}}}
  1028.   ;OCL{{{  call-mouse-menu
  1029.   ( forward main-menu )
  1030.   ( forward move-menu )
  1031.   ( deffun call-mouse-menu
  1032.      ( case
  1033.         ( buffer-moving ( b-m-menu ) )
  1034.         ( moving ( move-menu ) )
  1035.        default
  1036.         ( main-menu )
  1037.        esac
  1038.      )
  1039.   )
  1040.   ;OCL}}}
  1041.   ;OCL{{{  handle-mouse
  1042.   ( defvar ( g-a-c-m-l ) )
  1043.   ( forward ( x ) indent-region-sub )
  1044.   ( deffun ( cmd ) handle-mouse
  1045.      ( case
  1046.         ;OCL{{{  shell-mode
  1047.         @if-using ( SHELL-MODE )
  1048.            ( shell-mode-active ( shell-mouse(cmd) ) )
  1049.         @fi
  1050.         ;OCL}}}
  1051.         ;OCL{{{  indent-region -> shift to or abort
  1052.         ( irline
  1053.            ( if <(mouse-outside 0)
  1054.               ( switch-to-edit-mode )
  1055.              else
  1056.               ( indent-region-sub( -(mouse-x store-pos) ) )
  1057.              fi
  1058.            )
  1059.         )
  1060.         ;OCL}}}
  1061.         ;OCL{{{  prompt -> nop
  1062.         ( or(in-prompt prompting) ( ) )
  1063.         ;OCL}}}
  1064.         ;OCL{{{  buffer -> switch or menu
  1065.         ( <>(buffer-moving 0)
  1066.            ( if <(mouse-outside 0)
  1067.               ( b-m-menu )
  1068.              else
  1069.               ( if <>(current-buffer-number mouse-buffer-number)
  1070.                  ( switch-off-buffer-handling
  1071.                    goto-buffer-number mouse-buffer-number
  1072.                    switch-on-buffer-handling
  1073.                  )
  1074.                 fi
  1075.               )
  1076.              fi
  1077.            )
  1078.         )
  1079.         ;OCL}}}
  1080.         ;OCL{{{  other window -> switch buffer
  1081.         ( and
  1082.            ( >=(mouse-outside 0)
  1083.              <>(mouse-buffer-number current-buffer-number)
  1084.            )
  1085.            ( if moving
  1086.               ( bell
  1087.                 visible-bell
  1088.                 message ( M_ERR_PO )
  1089.               )
  1090.              else
  1091.               ( go-mouse-position )
  1092.              fi
  1093.            )
  1094.         )
  1095.         ;OCL}}}
  1096.         ;OCL{{{  on text-> go and act depending on button
  1097.         ( or(=(mouse-outside 0) =(mouse-outside 1))
  1098.            ( screen-off
  1099.              go-mouse-position
  1100.              case
  1101.               ;OCL{{{  cmd > 0 -> enter or open
  1102.               ( >(cmd 0)
  1103.                  ( case
  1104.                     ;OCL{{{  fold -> open
  1105.                     ( test-fold-line
  1106.                        ( open-fold
  1107.                          screen-on
  1108.                          redraw-display
  1109.                        )
  1110.                     )
  1111.                     ;OCL}}}
  1112.                     ;OCL{{{  filed -> maybe enter
  1113.                     ( test-filed
  1114.                        ( screen-on
  1115.                          redraw-display
  1116.                          if
  1117.                             not
  1118.                              ( or
  1119.                                 ( moving
  1120.                                   and
  1121.                                    ( ocl-argument
  1122.                                      pre ( set cmd -(cmd 1) ) =(cmd 0)
  1123.                                    )
  1124.                                 )
  1125.                              )
  1126.                           ( enter-fold )
  1127.                          fi
  1128.                        )
  1129.                     )
  1130.                     ;OCL}}}
  1131.                    default
  1132.                     ( screen-on
  1133.                       redraw-display
  1134.                     )
  1135.                    esac
  1136.                  )
  1137.               )
  1138.               ;OCL}}}
  1139.               ;OCL{{{  cmd = 0 -> center
  1140.               ( =(cmd 0)
  1141.                  ( screen-on
  1142.                    center-and-redraw-display
  1143.                    describe-fold
  1144.                  )
  1145.               )
  1146.               ;OCL}}}
  1147.              default
  1148.               ;OCL{{{  cmd < 0 -> close
  1149.               ( set-counter g-a-c-m-l cursor-level
  1150.                 if last-message M_USE_EXIT ( ) fi
  1151.                 if last-message M_TOP ( ) fi
  1152.                 close-fold
  1153.                 set cmd +(cmd 1)
  1154.                 case
  1155.                  ( and(ocl-argument =(cmd 0)) ( ) )
  1156.                 default
  1157.                  ( if or
  1158.                        ( last-message M_TOP
  1159.                          last-message M_USE_EXIT
  1160.                          <>(cmd 0)  ; -> cmd was set to value < -1
  1161.                        )
  1162.                     ( screen-on
  1163.                       redraw-display
  1164.                       exit-fold
  1165.                       return-from-macro
  1166.                     )
  1167.                    fi
  1168.                  )
  1169.                 esac
  1170.                 screen-on
  1171.                 set-cursor-line g-a-c-m-l
  1172.               )
  1173.               ;OCL}}}
  1174.              esac
  1175.            )
  1176.         )
  1177.         ;OCL}}}
  1178.        default
  1179.         ( call-mouse-menu )
  1180.        esac
  1181.      )
  1182.   )
  1183.   ( undeclare ( g-a-c-m-l ) )
  1184.   ;OCL}}}
  1185.   ;OCL{{{  go-and-open-mouse
  1186.   ( deffun go-and-open-mouse ( handle-mouse(1) ) )
  1187.   ;OCL}}}
  1188.   ;OCL{{{  go-and-close-mouse
  1189.   ( deffun go-and-close-mouse ( handle-mouse(-1) ) )
  1190.   ;OCL}}}
  1191.   ;OCL{{{  go-mouse-and-center
  1192.   ( deffun go-mouse-and-center ( handle-mouse(0) ) )
  1193.   ;OCL}}}
  1194.   @if-using ( FORCE-MOUSE-CMDS )
  1195.      ;OCL{{{  go-and-do-open-mouse
  1196.      ( deffun go-and-do-open-mouse ( handle-mouse(2) ) )
  1197.      ;OCL}}}
  1198.      ;OCL{{{  go-and-do-close-mouse
  1199.      ( deffun go-and-do-close-mouse ( handle-mouse(-2) ) )
  1200.      ;OCL}}}
  1201.   @fi
  1202.   ;OCL{{{  undeclares
  1203.   ( undeclare ( goto-window call-mouse-menu go-mouse-position handle-mouse ) )
  1204.   ;OCL}}}
  1205. @fi
  1206. ;OCL}}}
  1207. ;OCL{{{  yes-no-menu
  1208. ( defvar ( ynm-x ) )
  1209. ( deffun ( force ) yes-no-menu
  1210.    ( do
  1211.       ( set ynm-x 0
  1212.         begin-prompt-macro
  1213.         menu-counter ynm-x ( I_NO "  "/ "  I_YES "  "  "  history string-buffer )
  1214.         end-prompt-macro
  1215.       )
  1216.      while not(or(=(ynm-x 0) =(ynm-x 2)))
  1217.      if force
  1218.       ( if ynm-x ( insert-ascii I_YES ) else ( insert-ascii I_NO ) fi
  1219.         newline-and-indent
  1220.       )
  1221.      fi
  1222.      return-value-from-macro ynm-x
  1223.    )
  1224. )
  1225. ( undeclare ( ynm-x ) )
  1226. ;OCL}}}
  1227. ;OCL{{{  ref
  1228. ;OCL{{{  set tags
  1229. @if-using (NO-HELP-BROWSER)
  1230.    @use ( ModeOri-Reference-Card-REF  )
  1231. @fi
  1232. @if-using not(NO-HELP-BROWSER)
  1233.    @use
  1234.     ( REF-TREE
  1235.       ModeOri-Reference-Card-REF
  1236.       ModeOri-Reference-Card-TREE
  1237.       C-Operators-TREE
  1238.     )
  1239. @fi
  1240. ;OCL}}}
  1241. @lib modeori-fun/ref.ocl
  1242. ;OCL{{{  reset tags
  1243. @if-using (NO-HELP-BROWSER)
  1244.    @use not( ModeOri-Reference-Card-REF  )
  1245. @fi
  1246. @if-using not(NO-HELP-BROWSER)
  1247.    @use not
  1248.     ( REF-TREE
  1249.       ModeOri-Reference-Card-REF
  1250.       ModeOri-Reference-Card-TREE
  1251.       C-Operators-TREE
  1252.     )
  1253. @fi
  1254. ;OCL}}}
  1255. @if-using (NO-HELP-BROWSER)
  1256.    ( defmac mori-help ( help ) )
  1257.    ( defmac info ( mori-help ) )
  1258. @fi
  1259. @if-using not(NO-HELP-BROWSER)
  1260.    ;OCL{{{  info
  1261.    ( deffun info
  1262.       ( set prompting true
  1263.         ModeOri-Reference-Card
  1264.         set prompting false
  1265.       )
  1266.    )
  1267.    ;OCL}}}
  1268.    ;OCL{{{  mori-help
  1269.    ( deffun mori-help
  1270.       ( if last-message M_ANY_Q ( ) fi
  1271.         screen-off
  1272.         history-edit string-buffer ()
  1273.            insert-ascii I_BACK
  1274.            beginning-of-line
  1275.            set ocl-argument store-character
  1276.            newline-and-indent
  1277.         help
  1278.         screen-on
  1279.         if last-message M_ANY_Q
  1280.          ;OCL{{{  show page
  1281.          ( insert-ascii ocl-argument )
  1282.          ;OCL}}}
  1283.         else
  1284.          ;OCL{{{  show mode dependent reference
  1285.          ( newline-and-indent
  1286.            case
  1287.             ;OCL{{{  language C -> operator hierarchy
  1288.             ( test-language C
  1289.                ( set prompting true
  1290.                  C-Operators
  1291.                  set prompting false
  1292.                )
  1293.             )
  1294.             ;OCL}}}
  1295.            default
  1296.             ;OCL{{{  reference data
  1297.             ( info )
  1298.             ;OCL}}}
  1299.            esac
  1300.          )
  1301.          ;OCL}}}
  1302.         fi
  1303.       )
  1304.    )
  1305.    ;OCL}}}
  1306.    ( undeclare ( ModeOri-Reference-Card C-Operators ) )
  1307. @fi
  1308. ;OCL}}}
  1309. ;OCL}}}
  1310. ;OCL{{{  edit mode macros
  1311. ;OCL{{{  unmodified libs
  1312. ;OCL{{{  xsel
  1313. @if-using ( W-GET-X-SEL )
  1314.    @lib xsel
  1315. @fi
  1316. ;OCL}}}
  1317. @lib trans-char
  1318. @lib buff-chg
  1319. @lib np-file
  1320. ;OCL}}}
  1321. ;OCL{{{  character-cases
  1322. ;OCL{{{  toggle-case-word
  1323. ( deffun toggle-case-word
  1324.    ( setup-char-sets
  1325.      ;OCL{{{  move to beginning of handled word
  1326.      if test-char-set word-char
  1327.       ( forward-character
  1328.         backward-word
  1329.       )
  1330.      else
  1331.       ( forward-word )
  1332.      fi
  1333.      ;OCL}}}
  1334.      if test-char-set word-char
  1335.       ;OCL{{{  handle word, move cursor behind
  1336.       ( do
  1337.          ;OCL{{{  maybe toggle single char
  1338.          ( if or
  1339.                ( =(0 modify-behaviour)
  1340.                  and(<(0 modify-behaviour) test-char-set lower)
  1341.                  and(>(0 modify-behaviour) test-char-set upper)
  1342.                )
  1343.             ( case-character-toggle )
  1344.            fi
  1345.            if =(2 modify-behaviour) ( set modify-behaviour -1 ) fi
  1346.          )
  1347.          ;OCL}}}
  1348.         while pre ( forward-character ) test-char-set word-char
  1349.       )
  1350.       ;OCL}}}
  1351.      fi
  1352.    )
  1353. )
  1354. ;OCL}}}
  1355. ;OCL{{{  uppercase-word
  1356. ( deffun uppercase-word
  1357.    ( set modify-behaviour 1
  1358.      toggle-case-word
  1359.      set modify-behaviour 0
  1360.    )
  1361. )
  1362. ;OCL}}}
  1363. ;OCL{{{  capitalize-word
  1364. ( deffun capitalize-word
  1365.    ( set modify-behaviour 2
  1366.      toggle-case-word
  1367.      set modify-behaviour 0
  1368.    )
  1369. )
  1370. ;OCL}}}
  1371. ;OCL{{{  lowercase-word
  1372. ( deffun lowercase-word
  1373.    ( set modify-behaviour -1
  1374.      toggle-case-word
  1375.      set modify-behaviour 0
  1376.    )
  1377. )
  1378. ;OCL}}}
  1379. ;OCL}}}
  1380. ;OCL{{{  error-buff
  1381. ( demand-load
  1382.    ( @lib error-buff
  1383.      ;OCL{{{  redefine show-error-buffer for using prompting
  1384.      ( deffun e-m-show-error-buffer
  1385.         ( set prompting true
  1386.           show-error-buffer
  1387.           set prompting false
  1388.         )
  1389.      )
  1390.      ( undeclare ( show-error-buffer ) )
  1391.      ( defmac show-error-buffer ( e-m-show-error-buffer ) )
  1392.      ( undeclare ( e-m-show-error-buffer ) )
  1393.      ;OCL}}}
  1394.    )
  1395. )
  1396. ;OCL}}}
  1397. ;OCL{{{  list-buffers
  1398. ( demand-load ( @lib listbuff ) )
  1399. ( deffun e-m-list-buffers
  1400.    ( set prompting true
  1401.      list-buffers
  1402.      set prompting false
  1403.      load-function not( list-buffers )
  1404.    )
  1405. )
  1406. ( undeclare ( list-buffers ) )
  1407. ;OCL}}}
  1408. ;OCL{{{  e-m-unfold
  1409. ( deffun e-m-unfold-fold
  1410.    ( if not(in-prompt)
  1411.       ( case
  1412.          ( test-filed ( describe-fold toggle-file-fold ) )
  1413.          ( not(test-fold-line) ( close-fold ) )
  1414.         esac
  1415.       )
  1416.      fi
  1417.      unfold-fold
  1418.    )
  1419. )
  1420. ;OCL}}}
  1421. ;OCL{{{  mode-position
  1422. ;OCL{{{  prepare redefining mode-commands
  1423. ( defvar ( show-position ) )
  1424. ( defmac amp ( add-mode-position ) )
  1425. ( defmac dmp ( delete-mode-position ) )
  1426. ( undeclare ( add-mode-position delete-mode-position ) )
  1427. ;OCL}}}
  1428. ;OCL{{{  add-mode-position
  1429. ( deffun add-mode-position ( set show-position 1 amp ) )
  1430. ;OCL}}}
  1431. ;OCL{{{  delete-mode-position
  1432. ( deffun delete-mode-position ( set show-position 0 dmp ) )
  1433. ;OCL}}}
  1434. ;OCL{{{  toggle-mode-position
  1435. ( deffun toggle-mode-position
  1436.    ( if show-position
  1437.       ( delete-mode-position )
  1438.      else
  1439.       ( add-mode-position )
  1440.      fi
  1441.    )
  1442. )
  1443. ;OCL}}}
  1444. ;OCL{{{  hide internal data
  1445. ( undeclare ( amp dmp ) )
  1446. ;OCL}}}
  1447. ;OCL}}}
  1448. ;OCL{{{  toggle-mode-overwrite
  1449. ( deffun toggle-mode-overwrite
  1450.    ( if test-overwrite
  1451.       ( delete-mode-overwrite )
  1452.      else
  1453.       ( add-mode-overwrite )
  1454.      fi
  1455.    )
  1456. )
  1457. ;OCL}}}
  1458. ;OCL{{{  buffer-handling
  1459. ;OCL{{{  read the lib
  1460. ( demand-load ( @lib file-buffers ) )
  1461. ;OCL{{{  mori-dump-buffers-to-file
  1462. ( deffun mori-dump-buffers-to-file
  1463.    ( delay-auto-save
  1464.      dump-buffers-to-file
  1465.      flush-auto-save
  1466.    )
  1467. )
  1468. ;OCL}}}
  1469. ;OCL{{{  mori-get-buffers-from-file
  1470. ( deffun mori-get-buffers-from-file
  1471.    ( delay-auto-save
  1472.      get-buffers-from-file
  1473.      flush-auto-save
  1474.    )
  1475. )
  1476. ;OCL}}}
  1477. ;OCL{{{  undeclares
  1478. ( undeclare ( dump-buffers-to-file get-buffers-from-file ) )
  1479. ;OCL}}}
  1480. ;OCL}}}
  1481. ;OCL{{{  add-mode-buffer-save
  1482. ( deffun add-mode-buffer-save ( set buff-saving 1 set-user-mode BS ) )
  1483. ;OCL}}}
  1484. ;OCL{{{  delete-mode-buffer-save
  1485. ( deffun delete-mode-buffer-save ( set buff-saving 0 reset-user-mode BS ) )
  1486. ;OCL}}}
  1487. ;OCL}}}
  1488. ;OCL{{{  e-m-create-fold
  1489. ( deffun e-m-create-fold
  1490.    (
  1491.      if and( extended-version not(test-folding) )
  1492.        ( switch-to-move-mode )
  1493.      else
  1494.       ( if highlight-off ( set modify-behaviour 5 ) fi
  1495.         create-fold
  1496.         set modify-behaviour 0
  1497.       )
  1498.      fi
  1499.    )
  1500. )
  1501. ;OCL}}}
  1502. ;OCL{{{  e-m-enter-fold
  1503. @lib search-enter
  1504. ( deffun e-m-enter-fold
  1505.    ( if extended-version
  1506.       ( set no-auto-change true
  1507.         search-and-enter-fold
  1508.         set no-auto-change false
  1509.       )
  1510.      else
  1511.       ( enter-fold )
  1512.      fi
  1513.    )
  1514. )
  1515. ( undeclare ( search-and-enter-fold ) )
  1516. ;OCL}}}
  1517. ;OCL{{{  e-m-save-file
  1518. ( deffun e-m-save-file
  1519.    ( if set-enter
  1520.       ( local
  1521.          ( go-line-arg )
  1522.          ( set go-line-arg store-line
  1523.            exit-fold
  1524.            e-m-save-file
  1525.            if not(in-prompt)
  1526.             ( enter-fold
  1527.               go-line
  1528.             )
  1529.            fi
  1530.          )
  1531.       )
  1532.      else
  1533.       ( save-file )
  1534.      fi
  1535.    )
  1536. )
  1537. ;OCL}}}
  1538. ;OCL{{{  auto-indent
  1539. ( defvar ( auto-indent ) )
  1540. ;OCL{{{  add-mode-auto-indent
  1541. ( deffun add-mode-auto-indent
  1542.    ( set auto-indent 1
  1543.      set-user-mode AI
  1544.    )
  1545. )
  1546. ;OCL}}}
  1547. ;OCL{{{  delete-mode-auto-indent
  1548. ( deffun delete-mode-auto-indent
  1549.    ( set auto-indent 0
  1550.      reset-user-mode AI
  1551.    )
  1552. )
  1553. ;OCL}}}
  1554. ;OCL{{{  e-m-newline-and-indent
  1555. ( deffun e-m-newline-and-indent
  1556.    ( if or(in-prompt >(auto-indent 0) not(test-text))
  1557.       ( newline-and-indent )
  1558.      else
  1559.       ( newline-and-indent
  1560.         "$
  1561.         goto-counter 1
  1562.         delspaces
  1563.         delete-character
  1564.       )
  1565.      fi
  1566.      do-mode-center
  1567.    )
  1568. )
  1569. ;OCL}}}
  1570. ;OCL}}}
  1571. ;OCL{{{  unchange-and-reread-file
  1572. ( deffun unchange-and-reread-file
  1573.    ( case
  1574.       ( in-prompt ( ) )
  1575.       ( test-folding ( message ( M_NOFOLDKEY ) ) )
  1576.      default
  1577.       ( screen-off
  1578.         set-file-unchanged
  1579.         enter-list-file "0 newline-and-indent
  1580.         exit-fold
  1581.         screen-on
  1582.         redraw-display
  1583.       )
  1584.      esac
  1585.    )
  1586. )
  1587. ;OCL}}}
  1588. ;OCL{{{  mode-diredit-long
  1589. ;OCL{{{  add-mode-diredit-long
  1590. ( deffun add-mode-diredit-long
  1591.    ( set diredit-long 1
  1592.      if =(file-type 1)
  1593.       ( unchange-and-reread-file )
  1594.      fi
  1595.    )
  1596. )
  1597. ;OCL}}}
  1598. ;OCL{{{  delete-mode-diredit-long
  1599. ( deffun delete-mode-diredit-long
  1600.    ( set diredit-long 0
  1601.      if =(file-type 1)
  1602.       ( unchange-and-reread-file )
  1603.      fi
  1604.    )
  1605. )
  1606. ;OCL}}}
  1607. ;OCL{{{  toggle-mode-diredit-long
  1608. ( deffun toggle-mode-diredit-long
  1609.    ( set diredit-long -(1 diredit-long)
  1610.      if diredit-long
  1611.       ( message ( "[ "long "  "directory "  "mode! "] ) )
  1612.      else
  1613.       ( message ( "[ "short "  "directory "  "mode! "] ) )
  1614.      fi
  1615.      if =(file-type 1)
  1616.       ( unchange-and-reread-file )
  1617.      fi
  1618.    )
  1619. )
  1620. ;OCL}}}
  1621. ;OCL}}}
  1622. ;OCL{{{  fill-paragraph
  1623. ( demand-load (
  1624.    @lib fillpara
  1625.    ;OCL{{{  e-m-fill-paragraph
  1626.    ( deffun e-m-fill-paragraph
  1627.       ( delete-mode-full-shift
  1628.         message ()
  1629.         if >(show-position 0)
  1630.          ( delete-mode-position
  1631.            fill-paragraph
  1632.            add-mode-position
  1633.          )
  1634.         else
  1635.          ( fill-paragraph )
  1636.         fi
  1637.         if full-shifting
  1638.          ( add-mode-full-shift
  1639.            message ()
  1640.          )
  1641.         fi
  1642.       )
  1643.    )
  1644.    ;OCL}}}
  1645.    ;OCL{{{  e-m-set-fill-column
  1646.    ( deffun e-m-set-fill-column
  1647.       ( set prompting true
  1648.         set-fill-column
  1649.         set prompting false
  1650.       )
  1651.    )
  1652.    ;OCL}}}
  1653.    ;OCL{{{  e-m-set-fill-mode
  1654.    ( deffun e-m-set-fill-mode
  1655.       ( set prompting true
  1656.         set-fill-mode
  1657.         set prompting false
  1658.       )
  1659.    )
  1660.    ;OCL}}}
  1661.    ;OCL{{{  undeclares
  1662.    ( undeclare ( fill-paragraph ) )
  1663.    ;OCL}}}
  1664. ) )
  1665. ;OCL}}}
  1666. ;OCL{{{  tags
  1667. @use ( T-COMP O-T-FILE FE-G-T-BUFF S-N-I-T Q-U-G-T-BUFF I-T-FILE O-T-AFILE )
  1668. @lib tags-mac
  1669. @use not( T-COMP O-T-FILE FE-G-T-BUFF S-N-I-T Q-U-G-T-BUFF I-T-FILE O-T-AFILE )
  1670. ( deffun e-m-find-or-enter-and-go-tags-buffer
  1671.    ( set prompting true
  1672.      find-or-enter-and-go-tags-buffer
  1673.      set prompting false
  1674.    )
  1675. )
  1676. ;OCL}}}
  1677. ;OCL{{{  call-cmd
  1678. ( deffun ( t ) call-cmd
  1679.    ( screen-off
  1680.      history-edit-filename shell ()
  1681.         ;OCL{{{  get change directory command
  1682.         local ()
  1683.          ( end-of-line
  1684.            ;OCL{{{  directories have to be handled in a special way!
  1685.            case
  1686.             ( =(file-type -1) ( beginning-of-line ) )
  1687.             ( =(file-type 1)  ( insert-ascii path-separator ) )
  1688.            esac
  1689.            ;OCL}}}
  1690.            while true
  1691.             ( case
  1692.                ;OCL{{{  delete filename and gen 'cd dir;'
  1693.                ( test-char path-separator
  1694.                   ( delete-to-end-of-line
  1695.                     cmd-separator
  1696.                     beginning-of-line
  1697.                     cd-cmd "  ;
  1698.                     end-of-line
  1699.                     return-from-macro
  1700.                   )
  1701.                )
  1702.                ;OCL}}}
  1703.                ;OCL{{{  no cd needed
  1704.                ( test-begin-line
  1705.                   ( delete-to-end-of-line
  1706.                     return-from-macro
  1707.                   )
  1708.                )
  1709.                ;OCL}}}
  1710.               default
  1711.                ( backward-character )
  1712.               esac
  1713.             )
  1714.          )
  1715.         ;OCL}}}
  1716.         case
  1717.          ( =(t 0) ( get-history make-cmd-hist 0 ) )
  1718.          ( >(t 0) ( get-history mail-cmd-hist 0 ) )
  1719.         esac
  1720.         newline-and-indent
  1721.      screen-on
  1722.      local
  1723.       ( force-bourne-shell )
  1724.       ( set force-bourne-shell true
  1725.         shell-command
  1726.            previous-line
  1727.            newline-and-indent
  1728.       )
  1729.    )
  1730. )
  1731. ;OCL}}}
  1732. ;OCL{{{  call-make
  1733. ( deffun call-make ( call-cmd(0) ) )
  1734. ;OCL}}}
  1735. ;OCL{{{  call-postbox
  1736. ( deffun call-postbox ( call-cmd(1) ) )
  1737. ;OCL}}}
  1738. ;OCL{{{  e-m-filename-completion
  1739. ( defvar ( f-c-verbose ) )
  1740. ( deffun e-m-filename-completion
  1741.    (
  1742.      ;OCL{{{  prehandle verbose
  1743.      set f-c-verbose false
  1744.      if test-verbose
  1745.       ( set f-c-verbose true
  1746.         delete-mode-verbose
  1747.       )
  1748.      fi
  1749.      ;OCL}}}
  1750.      filename-completion
  1751.      if and(=(ocl-argument 0) not(in-prompt) extended-version)
  1752.       ( tag-completion )
  1753.      fi
  1754.      ;OCL{{{  posthandle verbose and maybe bell
  1755.      if f-c-verbose
  1756.       ( add-mode-verbose
  1757.         if =(ocl-argument 0)
  1758.          ( bell
  1759.            visible-bell
  1760.          )
  1761.         fi
  1762.       )
  1763.      fi
  1764.      ;OCL}}}
  1765.    )
  1766. )
  1767. ( undeclare ( f-c-verbose ) )
  1768. ;OCL}}}
  1769. ;OCL{{{  language-dependent extensions for '"..
  1770. @if-using (L-EXT)
  1771.    ;OCL{{{  help vars
  1772.    ( defvar
  1773.       ( os-ext-help-1
  1774.         os-ext-help-2
  1775.         os-ext-help-3
  1776.         os-ext-help-4
  1777.       )
  1778.    )
  1779.    ;OCL}}}
  1780.    ;OCL{{{  c-bracket
  1781.    ( defmac c-bracket
  1782.       (
  1783.         @if-using (MY-C-CB)
  1784.            my-c-cb
  1785.         @fi
  1786.         @if-using not(MY-C-CB)
  1787.          ;OCL{{{  {} at right position
  1788.            set os-ext-help-1 store-pos
  1789.            beginning-of-line
  1790.            if test-char "  ;
  1791.             ( goto-counter os-ext-help-1 )
  1792.            else
  1793.             ( set os-ext-help-1 store-pos
  1794.               if test-char "{ ( set os-ext-help-1 +(os-ext-help-1 2) ) fi
  1795.               end-of-line
  1796.               newline-and-indent
  1797.               goto-counter os-ext-help-1
  1798.               "  ;
  1799.             )
  1800.            fi
  1801.            "{
  1802.            newline-and-indent
  1803.            "}
  1804.            previous-line
  1805.            "  ;
  1806.          ;OCL}}}
  1807.         @fi
  1808.       )
  1809.    )
  1810.    ;OCL}}}
  1811.    ;OCL{{{  ocl-bracket
  1812.    ( defmac ocl-bracket
  1813.       ( set os-ext-help-1 store-pos
  1814.         beginning-of-line
  1815.         if test-char "  ;
  1816.          ( goto-counter os-ext-help-1 )
  1817.         else
  1818.          ( set os-ext-help-1 store-pos
  1819.            if test-char "( ( set os-ext-help-1 +(os-ext-help-1 2) ) fi
  1820.            end-of-line
  1821.            newline-and-indent
  1822.            goto-counter os-ext-help-1
  1823.            "  ;
  1824.          )
  1825.         fi
  1826.         "(
  1827.         newline-and-indent
  1828.         ")
  1829.         previous-line
  1830.         "  ;
  1831.       )
  1832.    )
  1833.    ;OCL}}}
  1834.    ;OCL{{{  p-bracket
  1835.    ( defmac p-bracket
  1836.       (
  1837.         @if-using (MY-P-CB)
  1838.            my-p-cb
  1839.         @fi
  1840.         @if-using not(MY-P-CB)
  1841.          ;OCL{{{  begin/end at right position
  1842.            set os-ext-help-1 store-pos
  1843.            beginning-of-line
  1844.            if not(test-char " )
  1845.             ( set os-ext-help-1 store-pos
  1846.               end-of-line
  1847.               newline-and-indent "  "  ;
  1848.             )
  1849.            else
  1850.             ( goto-counter os-ext-help-1 )
  1851.            fi
  1852.            "begin
  1853.            newline-and-indent
  1854.            newline-and-indent
  1855.            "end
  1856.            previous-line
  1857.            backward-character
  1858.          ;OCL}}}
  1859.         @fi
  1860.       )
  1861.    )
  1862.    ;OCL}}}
  1863.    ;OCL{{{  parens
  1864.    ( deffun paired-parens
  1865.       ( "(
  1866.         if
  1867.           and
  1868.            ( >(extended-version 0)
  1869.              not(in-prompt)
  1870.              or
  1871.               ( test-language Pascal
  1872.                 test-language C
  1873.                 test-language Occam
  1874.                 test-language Inmos
  1875.                 test-language TeX
  1876.                 eval ( test-language-ocl )
  1877.               )
  1878.            )
  1879.          ( ") backward-character )
  1880.         fi
  1881.       )
  1882.    )
  1883.    ;OCL}}}
  1884.    ;OCL{{{  brackets
  1885.    ( deffun paired-brackets
  1886.       ( "[
  1887.         if
  1888.            and
  1889.             ( >(extended-version 0)
  1890.               not(in-prompt)
  1891.               or
  1892.                ( test-language Pascal
  1893.                  test-language C
  1894.                  test-language Occam
  1895.                  test-language Inmos
  1896.                )
  1897.             )
  1898.          ( "] backward-character )
  1899.         fi
  1900.       )
  1901.    )
  1902.    ;OCL}}}
  1903.    ;OCL{{{  curly brackets
  1904.    ( deffun paired-curly-brackets
  1905.       ( case
  1906.          (not(>(extended-version 0))())
  1907.          (in-prompt ())
  1908.          (not(test-text) ())
  1909.          ;OCL{{{  c-mode
  1910.          ( test-language C ( c-bracket return-from-macro ) )
  1911.          ;OCL}}}
  1912.          ;OCL{{{  p-mode
  1913.          ( test-language Pascal ( p-bracket return-from-macro ) )
  1914.          ;OCL}}}
  1915.          ;OCL{{{  occam
  1916.          ( or(test-language Inmos test-language Occam)
  1917.             ( end-of-line
  1918.               newline-and-indent
  1919.               "SEQ
  1920.               newline-and-indent
  1921.               "  "  ;
  1922.               return-from-macro
  1923.             )
  1924.          )
  1925.          ;OCL}}}
  1926.          ;OCL{{{  ocl
  1927.          ( eval ( test-language-ocl ) ( ocl-bracket return-from-macro ) )
  1928.          ;OCL}}}
  1929.         esac
  1930.         "{
  1931.       )
  1932.    )
  1933.    ;OCL}}}
  1934.    ;OCL{{{  doublequotes
  1935.    ( deffun doublequotes
  1936.       ( ""
  1937.         if and
  1938.             ( >(extended-version 0)
  1939.               not(in-prompt)
  1940.             )
  1941.           ( case
  1942.              ( or
  1943.                 ( test-language Pascal
  1944.                   test-language C
  1945.                   test-language Occam
  1946.                   test-language Inmos
  1947.                 )
  1948.                ( "" backward-character )
  1949.              )
  1950.              ( eval ( test-language-ocl )
  1951.                 ( "  backward-character )
  1952.              )
  1953.             esac
  1954.           )
  1955.          fi
  1956.    ))
  1957.    ;OCL}}}
  1958.    ;OCL{{{  singlequotes
  1959.    ( deffun singlequotes
  1960.       ( "'
  1961.         if
  1962.            and
  1963.             ( >(extended-version 0)
  1964.               not(in-prompt)
  1965.               or
  1966.                ( test-language Pascal
  1967.                  test-language C
  1968.                  test-language Occam
  1969.                  test-language Inmos
  1970.                )
  1971.             )
  1972.          ( "' backward-character )
  1973.         fi
  1974.       )
  1975.    )
  1976.    ;OCL}}}
  1977.    ;OCL{{{  semicolon
  1978.    ( deffun semicolon
  1979.       ( if
  1980.            and
  1981.             ( >(extended-version 0)
  1982.               not(in-prompt)
  1983.               test-text
  1984.             )
  1985.          ( case
  1986.             ;OCL{{{  c or pascal
  1987.             ( or
  1988.                ( test-language C
  1989.                  test-language Pascal
  1990.                )
  1991.               @if-using (MY-L-SEMICOLON)
  1992.                ( my-l-semicolon )
  1993.               @fi
  1994.               @if-using not(MY-L-SEMICOLON)
  1995.                ;OCL{{{  language
  1996.                (
  1997.                  ;OCL{{{  gen ; at correct position
  1998.                  set os-ext-help-1 store-pos
  1999.                  beginning-of-line
  2000.                  if test-char "  ;
  2001.                   ( goto-counter os-ext-help-1
  2002.                    ";
  2003.                   )
  2004.                  else
  2005.                   ( end-of-line
  2006.                     backward-character
  2007.                     if not(test-char "; ) ( forward-character "; ) fi
  2008.                   )
  2009.                  fi
  2010.                  ;OCL}}}
  2011.                  ;OCL{{{  where must next line begin
  2012.                  beginning-of-line
  2013.                  set os-ext-help-1 store-pos
  2014.                  if and(test-language C test-char "{)
  2015.                   ( set os-ext-help-1 +(os-ext-help-1 2) )
  2016.                  fi
  2017.                  ;OCL}}}
  2018.                  next-line
  2019.                  beginning-of-line
  2020.                  if test-char "  ;
  2021.                   ;OCL{{{  empty line, move to position
  2022.                   ( goto-counter os-ext-help-1 )
  2023.                   ;OCL}}}
  2024.                  else
  2025.                   ;OCL{{{  maybe generate new line
  2026.                   ( set os-ext-help-2 os-ext-help-1
  2027.                     set os-ext-help-1 -(os-ext-help-1 store-pos)
  2028.                     if or(not(test-text) >(os-ext-help-1 0))
  2029.                      ( previous-line
  2030.                        end-of-line
  2031.                        newline-and-indent
  2032.                        goto-counter os-ext-help-2
  2033.                      )
  2034.                     fi
  2035.                   )
  2036.                   ;OCL}}}
  2037.                  fi
  2038.                  return-from-macro
  2039.                )
  2040.                ;OCL}}}
  2041.               @fi
  2042.             )
  2043.             ;OCL}}}
  2044.             ;OCL{{{  OCL
  2045.             ( eval ( test-language-ocl )
  2046.                (
  2047.                  ;OCL{{{  where must next line begin
  2048.                  beginning-of-line
  2049.                  set os-ext-help-1 store-pos
  2050.                  if test-char "(
  2051.                   ( set os-ext-help-1 +(os-ext-help-1 2) )
  2052.                  fi
  2053.                  ;OCL}}}
  2054.                  next-line
  2055.                  beginning-of-line
  2056.                  if test-char "  ;
  2057.                   ;OCL{{{  empty line, move to position
  2058.                   ( goto-counter os-ext-help-1 )
  2059.                   ;OCL}}}
  2060.                  else
  2061.                   ;OCL{{{  maybe generate new line
  2062.                   ( set os-ext-help-2 os-ext-help-1
  2063.                     set os-ext-help-1 -(os-ext-help-1 store-pos)
  2064.                     if or(not(test-text) >(os-ext-help-1 0))
  2065.                      ( previous-line
  2066.                        end-of-line
  2067.                        newline-and-indent
  2068.                        goto-counter os-ext-help-2
  2069.                      )
  2070.                     fi
  2071.                   )
  2072.                   ;OCL}}}
  2073.                  fi
  2074.                  return-from-macro
  2075.                )
  2076.             )
  2077.             ;OCL}}}
  2078.            esac
  2079.          )
  2080.         fi
  2081.         ";
  2082.       )
  2083.    )
  2084.    ;OCL}}}
  2085.    ;OCL{{{  language-struct
  2086.    ( demand-load (
  2087.       ( deffun language-struct
  2088.          (
  2089.            if test-text
  2090.             ( para
  2091.               set os-ext-help-1 0
  2092.               menu-counter os-ext-help-1 ( "none "  "for "  "while-do "  "do-while "  "case )
  2093.               edit
  2094.               case
  2095.                (=(os-ext-help-1 0) ( return-from-macro ) )
  2096.                ;OCL{{{  for statement
  2097.                ( pre ( set os-ext-help-1 -(os-ext-help-1 1) ) =(os-ext-help-1 0)
  2098.                   ( case
  2099.                      ;OCL{{{  C
  2100.                      ( test-language C
  2101.                         ( "for "  paired-parens "; "; c-bracket
  2102.                           return-from-macro
  2103.                         )
  2104.                      )
  2105.                      ;OCL}}}
  2106.                      ;OCL{{{  PASCAL
  2107.                      ( test-language Pascal
  2108.                         ( "for "  "to p-bracket
  2109.                           return-from-macro
  2110.                         )
  2111.                      )
  2112.                      ;OCL}}}
  2113.                     esac
  2114.                   )
  2115.                )
  2116.                ;OCL}}}
  2117.                ;OCL{{{  while statement
  2118.                ( pre ( set os-ext-help-1 -(os-ext-help-1 1) ) =(os-ext-help-1 0)
  2119.                   ( case
  2120.                      ;OCL{{{  OCL
  2121.                      ( eval ( test-language-ocl )
  2122.                         ( "while
  2123.                           ocl-bracket
  2124.                           return-from-macro
  2125.                         
  2126.                         )
  2127.                      )
  2128.                      ;OCL}}}
  2129.                      ;OCL{{{  C
  2130.                      ( test-language C
  2131.                         ( "while "  "( ") c-bracket
  2132.                           return-from-macro
  2133.                         )
  2134.                      )
  2135.                      ;OCL}}}
  2136.                      ;OCL{{{  PASCAL
  2137.                      ( test-language Pascal
  2138.                         ( "while "  "do p-bracket
  2139.                           return-from-macro
  2140.                         )
  2141.                      )
  2142.                      ;OCL}}}
  2143.                     esac
  2144.                   )
  2145.                )
  2146.                ;OCL}}}
  2147.                ;OCL{{{  do statement
  2148.                ( pre ( set os-ext-help-1 -(os-ext-help-1 1) ) =(os-ext-help-1 0)
  2149.                   ( case
  2150.                      ;OCL{{{  OCL
  2151.                      ( eval ( test-language-ocl )
  2152.                         ( set os-ext-help-3 store-pos
  2153.                           "do
  2154.                           ocl-bracket
  2155.                           set os-ext-help-4 store-pos
  2156.                           next-line
  2157.                           end-of-line
  2158.                           newline-and-indent
  2159.                           goto os-ext-help-3
  2160.                           "while
  2161.                           previous-line
  2162.                           previous-line
  2163.                           goto os-ext-help-4
  2164.                           return-from-macro
  2165.                         )
  2166.                      )
  2167.                      ;OCL}}}
  2168.                      ;OCL{{{  C
  2169.                      ( test-language C
  2170.                         ( set os-ext-help-3 store-pos
  2171.                           "do
  2172.                           c-bracket
  2173.                           set os-ext-help-4 store-pos
  2174.                           next-line
  2175.                           end-of-line
  2176.                           newline-and-indent
  2177.                           goto os-ext-help-3
  2178.                           "while "  "( ") ";
  2179.                           previous-line
  2180.                           previous-line
  2181.                           goto os-ext-help-4
  2182.                           return-from-macro
  2183.                         )
  2184.                      )
  2185.                      ;OCL}}}
  2186.                      ;OCL{{{  Pascal
  2187.                      ( test-language Pascal
  2188.                         ( set os-ext-help-3 store-pos
  2189.                           "repeat
  2190.                           p-bracket
  2191.                           set os-ext-help-4 store-pos
  2192.                           next-line
  2193.                           end-of-line
  2194.                           newline-and-indent
  2195.                           goto os-ext-help-3
  2196.                           "until
  2197.                           previous-line
  2198.                           previous-line
  2199.                           goto os-ext-help-4
  2200.                           return-from-macro
  2201.                         )
  2202.                      )
  2203.                      ;OCL}}}
  2204.                     esac
  2205.                   )
  2206.                )
  2207.                ;OCL}}}
  2208.                ;OCL{{{  case statement
  2209.                ( pre ( set os-ext-help-1 -(os-ext-help-1 1) ) =(os-ext-help-1 0)
  2210.                   ( case
  2211.                      ;OCL{{{  C
  2212.                      ( test-language C
  2213.                         ( "switch "  "( ") c-bracket
  2214.                           return-from-macro
  2215.                         )
  2216.                      )
  2217.                      ;OCL}}}
  2218.                     esac
  2219.                   )
  2220.                )
  2221.                ;OCL}}}
  2222.               esac
  2223.             )
  2224.            fi
  2225.            message ( "not "  "supported )
  2226.          )
  2227.       )
  2228.    ) )
  2229.    ;OCL}}}
  2230.    ;OCL{{{  undeclare help vars
  2231.    ( undeclare
  2232.       ( os-ext-help-1
  2233.         os-ext-help-2
  2234.         os-ext-help-3
  2235.         os-ext-help-4
  2236.         c-bracket
  2237.         p-bracket
  2238.       )
  2239.    )
  2240.    ;OCL}}}
  2241. @fi
  2242. ;OCL}}}
  2243. ;OCL{{{  highlighting
  2244. ( deffun add-mode-highlight ( set highlight-off 0 ) )
  2245. ( deffun delete-mode-highlight ( set highlight-off 1 ) )
  2246. ;OCL}}}
  2247. ;OCL{{{  mode-parse
  2248. ( defmac add-mode-parse ( delete-mode-no-parse ) )
  2249. ( defmac delete-mode-parse ( add-mode-no-parse ) )
  2250. ;OCL}}}
  2251. ;OCL{{{  exit-origami
  2252. ( deffun exit-origami
  2253.    ( if >(used-buffers 1)
  2254.       ( screen-off )
  2255.      fi
  2256.      while not(test-file-changed)
  2257.       ( exit-buffer
  2258.         if =(used-buffers 1)
  2259.          ( screen-on
  2260.            redraw-display
  2261.          )
  2262.         fi
  2263.       )
  2264.      screen-on
  2265.      redraw-display
  2266.      message ( "file "  "changed )
  2267.    )
  2268. )
  2269. ;OCL}}}
  2270. ;OCL{{{  fold-mark-menu
  2271. ( demand-load (
  2272.    ( deffun fold-mark-menu
  2273.       ( if test-folding ( return-from-macro ) fi
  2274.         set cmd-in 1
  2275.         para
  2276.         menu-counter cmd-in ( "Ok "  "Default "  "Pascal "  "Script "  "New)
  2277.         edit
  2278.         case
  2279.          ;OCL{{{  0 -> nothing to do
  2280.          ( =(cmd-in 0) ( ) )
  2281.          ;OCL}}}
  2282.          ;OCL{{{  1 -> default
  2283.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2284.             ( change-fold-mark
  2285.               newline-and-indent
  2286.               newline-and-indent
  2287.               newline-and-indent
  2288.               newline-and-indent
  2289.             )
  2290.          )
  2291.          ;OCL}}}
  2292.          ;OCL{{{  2 -> pascal
  2293.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2294.             ( change-fold-mark "<<<:::...>>> )
  2295.          )
  2296.          ;OCL}}}
  2297.          ;OCL{{{  3 -> script
  2298.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2299.             ( change-fold-mark "##@##:...##$ )
  2300.          )
  2301.          ;OCL}}}
  2302.          ;OCL{{{  4 -> new
  2303.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2304.             ( change-fold-mark return-from-macro )
  2305.          )
  2306.          ;OCL}}}
  2307.         default
  2308.          ( abort-macro )
  2309.         esac
  2310.         message ( )
  2311.       )
  2312.    )
  2313. ) )
  2314. ;OCL}}}
  2315. ;OCL{{{  spell
  2316. ( demand-load
  2317.    (
  2318.      ;OCL{{{  mode spell-pause
  2319.      ( defmodestring SP "SpellPause "SpellPause )
  2320.      ;OCL}}}
  2321.      @use ( PRE-SPELL-EDIT-COMMAND )
  2322.      ;OCL{{{  pre-spell-edit-command
  2323.      ( defmac pre-spell-edit-command
  2324.         ( set prompting false
  2325.           set-user-mode SP
  2326.           message-exit ( "[ "spell "  "suspended "  "for "  "editing, "  "use "  "spell-buffer "  "to "  "continue "] )
  2327.         )
  2328.      )
  2329.      ;OCL}}}
  2330.      @lib spell
  2331.      @use not( PRE-SPELL-EDIT-COMMAND )
  2332.      ;OCL{{{  e-m-spell-buffer
  2333.      ( deffun e-m-spell-buffer
  2334.         ( set prompting true
  2335.           reset-user-mode SP
  2336.           spell-buffer
  2337.           set prompting false
  2338.           load-function not( spell-buffer )
  2339.         )
  2340.      )
  2341.      ;OCL}}}
  2342.      ( undeclare ( pre-spell-edit-command ) )
  2343.    )
  2344. )
  2345. ;OCL}}}
  2346. ;OCL{{{  main-menu
  2347. ;OCL{{{  str-get
  2348. ( demand-load (
  2349.    ( deffun str-get
  2350.       ( set prompting true
  2351.         while true
  2352.          ( begin-prompt-macro
  2353.            prompt-char-counter cmd-in ()
  2354.            end-prompt-macro
  2355.            if =(cmd-in newline-and-indent)
  2356.             ( end-of-line
  2357.               set prompting false
  2358.               return-from-macro
  2359.             )
  2360.            fi
  2361.            insert-ascii cmd-in
  2362.          )
  2363.       )
  2364.    )
  2365. ) )
  2366. ;OCL}}}
  2367. ;OCL{{{  para-menu
  2368. ( demand-load (
  2369.    ;OCL{{{  cur-val-start
  2370.    ( defmac cur-val-start ( "( insert-ascii C-? ) )
  2371.    ;OCL}}}
  2372.    ;OCL{{{  cur-val-end
  2373.    ( deffun cur-val-end
  2374.       ( backward-character
  2375.         while not(test-char C-?)
  2376.          ( if test-char "  ;
  2377.             ( raw-delete-character
  2378.               "_
  2379.               backward-character
  2380.             )
  2381.            fi
  2382.            backward-character
  2383.          )
  2384.         raw-delete-character
  2385.         end-of-line
  2386.         ")
  2387.       )
  2388.    )
  2389.    ;OCL}}}
  2390.    ;OCL{{{  file-para-menu
  2391.    ( deffun file-para-menu
  2392.       ( if test-view ( message ( M_VIEW ) view-macro ) fi
  2393.         set cmd-in 1
  2394.         para
  2395.         menu-counter
  2396.            cmd-in
  2397.          (    "Ok
  2398.            "  "Language
  2399.            "  "Fold-marks
  2400.          )
  2401.         edit
  2402.         show-cursor 0
  2403.         case
  2404.          ( =(cmd-in 0) ( ) )
  2405.          ;OCL{{{  set-language
  2406.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( set-language ) )
  2407.          ;OCL}}}
  2408.          ;OCL{{{  fold-marks
  2409.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( fold-mark-menu ) )
  2410.          ;OCL}}}
  2411.         default
  2412.          ( abort-macro )
  2413.         esac
  2414.       )
  2415.    )
  2416.    ;OCL}}}
  2417.    ;OCL{{{  diredit-para-menu
  2418.    ( deffun diredit-para-menu
  2419.       ( set cmd-in 0
  2420.         ;OCL{{{  get menu string
  2421.         screen-off
  2422.         history-edit string-buffer ()
  2423.              "Ok
  2424.           "  "ToggleLong
  2425.           ;OCL{{{  match
  2426.           "  "Match
  2427.              cur-val-start
  2428.              get-history match 0
  2429.              cur-val-end
  2430.           ;OCL}}}
  2431.           ;OCL{{{  nomatch
  2432.           "  "NoMatch
  2433.              cur-val-start
  2434.              get-history no-match 0
  2435.              cur-val-end
  2436.           ;OCL}}}
  2437.           newline-and-indent
  2438.         screen-on
  2439.         ;OCL}}}
  2440.         para
  2441.         menu-counter cmd-in ( history string-buffer )
  2442.         edit
  2443.         show-cursor 0
  2444.         case
  2445.          ( =(cmd-in 0) ( ) )
  2446.          ;OCL{{{  toggle long diredit
  2447.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( toggle-mode-diredit-long ) )
  2448.          ;OCL}}}
  2449.          ;OCL{{{  match
  2450.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2451.             ( history-edit match "match
  2452.               str-get
  2453.               if test-begin-line ( ". ) fi
  2454.               newline-and-indent
  2455.             )
  2456.          )
  2457.          ;OCL}}}
  2458.          ;OCL{{{  nomatch
  2459.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2460.             ( history-edit no-match "no-match
  2461.               str-get
  2462.               if test-begin-line ( insert-ascii path-separator ) fi
  2463.               newline-and-indent
  2464.             )
  2465.          )
  2466.          ;OCL}}}
  2467.         default
  2468.          ( abort-macro )
  2469.         esac
  2470.       )
  2471.    )
  2472.    ;OCL}}}
  2473.    ;OCL{{{  command-para-menu
  2474.    ( deffun command-para-menu
  2475.       ( set cmd-in 0
  2476.         ;OCL{{{  get menu string
  2477.         screen-off
  2478.         history-edit string-buffer ()
  2479.               "Ok
  2480.            ;OCL{{{  spell
  2481.            "  "Spell
  2482.               cur-val-start
  2483.               get-history spell-command 0
  2484.               cur-val-end
  2485.            ;OCL}}}
  2486.            ;OCL{{{  make
  2487.            "  "Make
  2488.               cur-val-start
  2489.               get-history make-cmd-hist 0
  2490.               cur-val-end
  2491.            ;OCL}}}
  2492.            @if-using ( SHELL-MODE )
  2493.               ;OCL{{{  nn
  2494.               "  "Nn
  2495.                  cur-val-start
  2496.                  get-history I-nn-cmd 0
  2497.                  cur-val-end
  2498.               ;OCL}}}
  2499.            @fi
  2500.            ;OCL{{{  postbox
  2501.            "  "Postbox
  2502.               cur-val-start
  2503.               get-history mail-cmd-hist 0
  2504.               cur-val-end
  2505.            ;OCL}}}
  2506.            ;OCL{{{  tags
  2507.            "  "TagsFile
  2508.               cur-val-start
  2509.               get-history tags-file 0
  2510.               cur-val-end
  2511.            ;OCL}}}
  2512.            @if-using ( SHELL-MODE )
  2513.               if not(ocl-arg-field(15))
  2514.                ;OCL{{{  shell
  2515.                ( "  "EnableShell )
  2516.                ;OCL}}}
  2517.               fi
  2518.            @fi
  2519.            newline-and-indent
  2520.         screen-on
  2521.         ;OCL}}}
  2522.         para
  2523.         menu-counter cmd-in ( history string-buffer )
  2524.         edit
  2525.         show-cursor 0
  2526.         case
  2527.          ( =(cmd-in 0) ( ) )
  2528.          ;OCL{{{  spell
  2529.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2530.             ( history-edit spell-command "spell-command
  2531.               str-get
  2532.               if test-begin-line
  2533.                ( default-spell-command )
  2534.               fi
  2535.               newline-and-indent
  2536.             )
  2537.          )
  2538.          ;OCL}}}
  2539.          ;OCL{{{  make
  2540.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2541.             ( history-edit make-cmd-hist "make-command
  2542.               str-get
  2543.               if test-begin-line
  2544.                ( make-cmd-def )
  2545.               fi
  2546.               newline-and-indent
  2547.             )
  2548.          )
  2549.          ;OCL}}}
  2550.          ;OCL{{{  nn
  2551.          @if-using ( SHELL-MODE )
  2552.             ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2553.                ( history-edit I-nn-cmd "nn-command
  2554.                  str-get
  2555.                  if test-begin-line
  2556.                   ( nn-cmd-def )
  2557.                  fi
  2558.                  newline-and-indent
  2559.                )
  2560.             )
  2561.          @fi
  2562.          ;OCL}}}
  2563.          ;OCL{{{  postbox
  2564.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2565.             ( history-edit mail-cmd-hist "postbox-command
  2566.               str-get
  2567.               if test-begin-line
  2568.                ( mail-cmd-def )
  2569.               fi
  2570.               newline-and-indent
  2571.             )
  2572.          )
  2573.          ;OCL}}}
  2574.          ;OCL{{{  tags
  2575.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2576.             ( history-edit tags-file "tags-file
  2577.               str-get
  2578.               set tags-user-tags-file true
  2579.               if test-begin-line
  2580.                ( "default
  2581.                  set tags-user-tags-file false
  2582.                )
  2583.               fi
  2584.               newline-and-indent
  2585.             )
  2586.          )
  2587.          ;OCL}}}
  2588.          ;OCL{{{  shell
  2589.          @if-using ( SHELL-MODE )
  2590.             ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( add-mode-shell ) )
  2591.          @fi
  2592.          ;OCL}}}
  2593.         default
  2594.          ( abort-macro )
  2595.         esac
  2596.       )
  2597.    )
  2598.    ;OCL}}}
  2599. ) )
  2600. ( defmac para-menu
  2601.    ( set-user-mode PM
  2602.      set cmd-in 1
  2603.      para
  2604.      menu-counter
  2605.         cmd-in
  2606.       (    "Ok
  2607.         "  "FileParameter
  2608.         "  "DirEdit
  2609.         "  "CommandParameter
  2610.         "  "set-display-mode
  2611.       )
  2612.      edit
  2613.      reset-user-mode PM
  2614.      show-cursor 0
  2615.      case
  2616.       ( =(cmd-in 0) ( ) )
  2617.       ;OCL{{{  set-language
  2618.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( file-para-menu ) )
  2619.       ;OCL}}}
  2620.       ;OCL{{{  diredit-filter
  2621.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( diredit-para-menu ) )
  2622.       ;OCL}}}
  2623.       ;OCL{{{  command
  2624.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( command-para-menu ) )
  2625.       ;OCL}}}
  2626.       ;OCL{{{  set-display-mode
  2627.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( set-display-mode ) )
  2628.       ;OCL}}}
  2629.      default
  2630.       ( abort-macro )
  2631.      esac
  2632.      ;OCL{{{  unload inernal functions
  2633.      load-function not
  2634.       ( file-para-menu
  2635.         diredit-para-menu
  2636.         command-para-menu
  2637.         cur-val-end
  2638.       )
  2639.      ;OCL}}}
  2640.    )
  2641. )
  2642. ;OCL{{{  undeclares
  2643. ( undeclare
  2644.    ( file-para-menu
  2645.      cur-val-start
  2646.      cur-val-end
  2647.    )
  2648. )
  2649. ;OCL}}}
  2650. ;OCL}}}
  2651. ;OCL{{{  file-menu
  2652. ( defmac file-menu
  2653.    ( set-user-mode FM
  2654.      set cmd-in 1
  2655.      para
  2656.      menu-counter
  2657.         cmd-in
  2658.       (    "Ok
  2659.         "  "Save
  2660.         "  "Unchange
  2661.         "  "Read
  2662.         "  "Insert
  2663.         "  "List-of-edited-files
  2664.       )
  2665.      edit
  2666.      reset-user-mode FM
  2667.      case
  2668.       ( =(cmd-in 0) ( ) )
  2669.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( save-file ) )
  2670.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( set-file-unchanged ) )
  2671.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( read-file ) )
  2672.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( insert-file ) )
  2673.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2674.          ( read-list-file "0 newline-and-indent )
  2675.       )
  2676.      default
  2677.       ( abort-macro )
  2678.      esac
  2679.    )
  2680. )
  2681. ;OCL}}}
  2682. ;OCL{{{  mode-menu
  2683. ( defmac mode-menu
  2684.    ( set-user-mode TM
  2685.      set cmd-in 0
  2686.      para
  2687.      menu-counter
  2688.         cmd-in
  2689.       (    "Ok
  2690.         "  "View
  2691.         "  "Extend
  2692.         "  "Autosave
  2693.         "  "Write-over
  2694.         "  "Position
  2695.       )
  2696.      edit
  2697.      case
  2698.       ( =(cmd-in 0) ( ) )
  2699.       ;OCL{{{  toggle view
  2700.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2701.          ( if test-view ( delete-mode-view ) else ( add-mode-view ) fi )
  2702.       )
  2703.       ;OCL}}}
  2704.       ;OCL{{{  toggle extend
  2705.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2706.          ( case
  2707.             ( =(extended-version 0) ( delete-mode-extended ) )
  2708.             ( >(extended-version 0) ( set-mode-raw ) )
  2709.            default
  2710.             ( add-mode-extended )
  2711.            esac
  2712.          )
  2713.       )
  2714.       ;OCL}}}
  2715.       ;OCL{{{  toggle autosave
  2716.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2717.          ( if test-autosave
  2718.             ( delete-mode-autosave )
  2719.            else
  2720.             ( add-mode-autosave newline-and-indent )
  2721.            fi
  2722.          )
  2723.       )
  2724.       ;OCL}}}
  2725.       ;OCL{{{  toggle overwrite
  2726.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( toggle-mode-overwrite ) )
  2727.       ;OCL}}}
  2728.       ;OCL{{{  toggle position
  2729.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( toggle-mode-position ) )
  2730.       ;OCL}}}
  2731.      default
  2732.       ( abort-macro )
  2733.      esac
  2734.      reset-user-mode TM
  2735.    )
  2736. )
  2737. ;OCL}}}
  2738. @if-using ( SHELL-MODE ) ( forward shell-exit-origami ) @fi
  2739. ( deffun main-menu
  2740.    ( if in-prompt ( newline-and-indent return-from-macro ) fi
  2741.      set cmd-in 1
  2742.      para
  2743.      menu-counter
  2744.         cmd-in
  2745.       (    "Ok
  2746.         "  "Bindings
  2747.         @if-using not( NO-HELP-BROWSER ) "  "Info @fi
  2748.         "  "Help
  2749.         "  "File
  2750.         "  "MoveMode
  2751.         "  "Para
  2752.         "  "ToggleModes
  2753.         "  "Window
  2754.         "  "Exit
  2755.       )
  2756.      edit
  2757.      case
  2758.       (=(cmd-in 0) ( message ( ) ) )
  2759.       ;OCL{{{  describe-bindings
  2760.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( describe-bindings ) )
  2761.       ;OCL}}}
  2762.       ;OCL{{{  info
  2763.       @if-using not( NO-HELP-BROWSER )
  2764.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2765.             ( set prompting true
  2766.               info
  2767.               set prompting false
  2768.             )
  2769.          )
  2770.       @fi
  2771.       ;OCL}}}
  2772.       ;OCL{{{  help
  2773.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( mori-help ) )
  2774.       ;OCL}}}
  2775.       ;OCL{{{  file
  2776.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( file-menu ) )
  2777.       ;OCL}}}
  2778.       ;OCL{{{  move
  2779.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( switch-to-move-mode ) )
  2780.       ;OCL}}}
  2781.       ;OCL{{{  para
  2782.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( para-menu ) )
  2783.       ;OCL}}}
  2784.       ;OCL{{{  mode
  2785.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( mode-menu ) )
  2786.       ;OCL}}}
  2787.       ;OCL{{{  buffer
  2788.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2789.          ( switch-on-buffer-handling
  2790.            b-m-menu
  2791.          )
  2792.       )
  2793.       ;OCL}}}
  2794.       ;OCL{{{  exit
  2795.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  2796.          (
  2797.            ;OCL{{{  set prompt for really exit
  2798.            screen-off
  2799.            history-edit string-buffer ()
  2800.               "really "  "leave "  "editing
  2801.               newline-and-indent
  2802.            screen-on
  2803.            ;OCL}}}
  2804.            if eval ( yes-no-menu(false))
  2805.             ( @if-using    ( SHELL-MODE ) shell-exit-origami @fi
  2806.               @if-using not( SHELL-MODE ) exit-origami @fi
  2807.             )
  2808.            fi
  2809.          )
  2810.       )
  2811.       ;OCL}}}
  2812.      default
  2813.       ( abort-macro )
  2814.      esac
  2815.    )
  2816. )
  2817. ;OCL{{{  undeclares
  2818. ( undeclare ( mode-menu file-menu para-menu str-get ) )
  2819. ;OCL}}}
  2820. ;OCL}}}
  2821. ;OCL{{{  e-m-delete-to-end-of-line
  2822. ( defvar ( d2eol-x ) )
  2823. ( deffun e-m-delete-to-end-of-line
  2824.    ( if and(not(in-prompt) or(test-fold-line test-filed))
  2825.       ( set d2eol-x store-pos
  2826.         beginning-of-line
  2827.         if <=(d2eol-x store-pos)
  2828.          ( delete-line
  2829.            goto d2eol-x
  2830.            return-from-macro
  2831.          )
  2832.         fi
  2833.         goto d2eol-x
  2834.       )
  2835.      fi
  2836.      delete-to-end-of-line
  2837.    )
  2838. )
  2839. ;OCL}}}
  2840. ;OCL{{{  extend some simple commands for open-fold-lines
  2841. ;OCL{{{  front-fold-action
  2842. ( defvar ( action action-pos ) )
  2843. ( deffun front-fold-action
  2844.    ( if and(not(in-prompt) or(test-begin-fold test-end-fold))
  2845.       ( set action-pos store-pos
  2846.         beginning-of-line
  2847.         if not(>(-(action-pos store-pos) 0))
  2848.          ( if test-end-fold
  2849.             ( set action-pos cursor-level )
  2850.            else
  2851.             ( set action-pos 0 )
  2852.            fi
  2853.            screen-off
  2854.            close-fold
  2855.            if =(action delete-character)
  2856.             ( set action delete-previous-character )
  2857.            fi
  2858.            insert-ascii action
  2859.            open-fold
  2860.            if action-pos ( mtool-bot set-cursor-line action-pos ) fi
  2861.            do-mode-center
  2862.            screen-on
  2863.            redraw-display
  2864.            return-from-macro
  2865.          )
  2866.         fi
  2867.         goto-counter action-pos
  2868.       )
  2869.      fi
  2870.      insert-ascii action
  2871.    )
  2872. )
  2873. ;OCL}}}
  2874. ;OCL{{{  e-m-wrap-word
  2875. ( deffun e-m-wrap-word
  2876.    ( set action execute-number-macro wrap-word
  2877.      front-fold-action
  2878.    )
  2879. )
  2880. ;OCL}}}
  2881. ;OCL{{{  e-m-delete-character
  2882. ( deffun e-m-delete-character
  2883.    ( set action delete-character
  2884.      front-fold-action
  2885.    )
  2886. )
  2887. ;OCL}}}
  2888. ;OCL{{{  e-m-delete-previous-character
  2889. ( deffun e-m-delete-previous-character
  2890.    ( set action delete-previous-character
  2891.      front-fold-action
  2892.    )
  2893. )
  2894. ;OCL}}}
  2895. ;OCL}}}
  2896. ;OCL}}}
  2897. ;OCL{{{  move mode macros
  2898. ;OCL{{{  move-mode status vars
  2899. ( defvar
  2900.   (  was-view         ; was in view-mode
  2901.      edit-over        ; store old overwrite-status for complex commands
  2902.    )
  2903. )
  2904. ;OCL}}}
  2905. ;OCL{{{  select-no-highlight
  2906. ( deffun select-no-highlight
  2907.    ( if and(test-folding <>(ocl-argument 0)) ( create-fold ) fi )
  2908. )
  2909. ;OCL}}}
  2910. ;OCL{{{  select-highlight
  2911. ( deffun select-highlight
  2912.    ( set modify-behaviour -2
  2913.      if highlight-off ( set modify-behaviour -4 ) fi
  2914.      create-fold
  2915.      set modify-behaviour 0
  2916.    )
  2917. )
  2918. ;OCL}}}
  2919. ;OCL{{{  m-m-goto-line
  2920. ( deffun m-m-goto-line
  2921.    ( para
  2922.      prompt-counter go-line-arg ( M_GOTO "? "  )
  2923.      moves
  2924.      go-line
  2925.    )
  2926. )
  2927. ;OCL}}}
  2928. ;OCL{{{  store-move-modes
  2929. ( defmac store-move-modes
  2930.    (
  2931.      ;OCL{{{  store view
  2932.      set was-view counter test-view
  2933.      ;OCL}}}
  2934.      ;OCL{{{  store overwrite
  2935.      set edit-over false
  2936.      if test-overwrite
  2937.       ( set edit-over true
  2938.         delete-mode-overwrite
  2939.       )
  2940.      fi
  2941.      ;OCL}}}
  2942.      select-highlight
  2943.    )
  2944. )
  2945. ;OCL}}}
  2946. ;OCL{{{  restore-move-modes
  2947. ( defmac restore-move-modes
  2948.    (
  2949.      ;OCL{{{  restore view
  2950.      if was-view ( add-mode-view ) fi
  2951.      ;OCL}}}
  2952.      ;OCL{{{  restore overwrite
  2953.      if edit-over ( add-mode-overwrite ) fi
  2954.      ;OCL}}}
  2955.      select-no-highlight
  2956.    )
  2957. )
  2958. ;OCL}}}
  2959. ;OCL{{{  read the lib
  2960. @use (REGIONS-INDENT) @lib regions @use not(REGIONS-INDENT)
  2961. ;OCL}}}
  2962. ;OCL{{{  m-m-set-start-mark
  2963. ( deffun m-m-set-start-mark
  2964.    ( select-no-highlight
  2965.      set-start-mark
  2966.      select-highlight
  2967.    )
  2968. )
  2969. ;OCL}}}
  2970. ;OCL{{{  change-position
  2971. ( deffun change-position
  2972.    ( select-no-highlight
  2973.      set-end-mark
  2974.      select-highlight
  2975.      go-start-mark
  2976.      change-mark-counters
  2977.    )
  2978. )
  2979. ;OCL}}}
  2980. ;OCL{{{  region/buffer support macros
  2981. ;OCL{{{  fold-error
  2982. ( deffun fold-error
  2983.    ( if was-view ( add-mode-view ) fi
  2984.      bell
  2985.      visible-bell
  2986.      switch-to-edit-mode
  2987.      screen-on
  2988.      redraw-display
  2989.      message-exit ( "[ M_FOLDERR ", "  "switch "  "to "  "edit-mode "] )
  2990.    )
  2991. )
  2992. ;OCL}}}
  2993. ;OCL{{{  mov-check-view
  2994. ( deffun mov-check-view
  2995.    ( if test-view ( "  ) else ( select-no-highlight ) fi )
  2996. )
  2997. ;OCL}}}
  2998. ;OCL{{{  pretty-move-exit
  2999. ( deffun pretty-move-exit
  3000.    ( set command 1
  3001.      screen-on
  3002.      redraw-display
  3003.      switch-to-edit-mode
  3004.    )
  3005. )
  3006. ;OCL}}}
  3007. ;OCL{{{  handle-fold-op-join
  3008. ( deffun ( op ) handle-fold-op-join
  3009.    ( mov-check-view
  3010.      screen-off
  3011.      set-end-mark
  3012.      fold-region
  3013.      if folderr ( fold-error ) fi
  3014.      insert-ascii op
  3015.      if and(start-splitted end-splitted)
  3016.       ( combine-splitted-parts-start )
  3017.      fi
  3018.      pretty-move-exit
  3019.    )
  3020. )
  3021. ;OCL}}}
  3022. ;OCL{{{  in-at-position
  3023. ;OCL{{{  splitt-put-line
  3024. ( defvar ( y cy ) )
  3025. ( defmac splitt-put-line
  3026.    ( if test-text
  3027.       ;OCL{{{  maybe splitt the text-line
  3028.       (
  3029.         if and(test-text,
  3030.                ;OCL{{{  cursor inside a line
  3031.                or(test-end-line,
  3032.                   pre
  3033.                    ( set y store-pos
  3034.                      beginning-of-line
  3035.                      set cy store-pos
  3036.                      goto-counter y
  3037.                    )
  3038.                    >(store-pos cy)
  3039.                  )
  3040.                ;OCL}}}
  3041.               )
  3042.          ;OCL{{{  splitt
  3043.          ( set start-x store-pos
  3044.            set start-y store-line
  3045.            newline-and-indent
  3046.            set end-x store-pos
  3047.            set end-y store-line
  3048.          )
  3049.          ;OCL}}}
  3050.         else
  3051.          ;OCL{{{  don't splitt
  3052.          ( set start-y 0 )
  3053.          ;OCL}}}
  3054.         fi
  3055.       )
  3056.       ;OCL}}}
  3057.      else
  3058.       ;OCL{{{  else unkill before the line
  3059.       ( beginning-of-line
  3060.         set start-y 0
  3061.       )
  3062.       ;OCL}}}
  3063.      fi
  3064.    )
  3065. )
  3066. ( undeclare ( y cy ) )
  3067. ;OCL}}}
  3068. ;OCL{{{  variables
  3069. ( defvar ( in-line in-mark ) )
  3070. ;OCL}}}
  3071. ( deffun ( in-op ) in-at-position
  3072.    ( mov-check-view
  3073.      if not(test-text)
  3074.       ( switch-to-edit-mode
  3075.         return-from-macro
  3076.       )
  3077.      fi
  3078.      screen-off
  3079.      splitt-put-line
  3080.      ;OCL{{{  store information to check empty inserts
  3081.      set in-mark store-line-mark
  3082.      set in-line store-line
  3083.      ;OCL}}}
  3084.      insert-ascii in-op
  3085.      ;OCL{{{  check and maybe add empty insert
  3086.      goto-line-mark in-mark
  3087.      if =(in-line store-line)
  3088.       ( create-fold
  3089.         create-fold
  3090.         beginning-of-line
  3091.       )
  3092.      else
  3093.       ( previous-line )
  3094.      fi
  3095.      ;OCL}}}
  3096.      ;OCL{{{  get new end position, maybe remove fold around insert
  3097.      next-line
  3098.      set end-y store-line
  3099.      previous-line
  3100.      if test-fold-line
  3101.       ( unfold-fold
  3102.         set end-y -(end-y 2)
  3103.       )
  3104.      fi
  3105.      ;OCL}}}
  3106.      if start-y
  3107.       ;OCL{{{  maybe join lines
  3108.       ( if test-text
  3109.          ( beginning-of-line
  3110.            "$
  3111.            previous-line
  3112.            end-of-line
  3113.            while test-char "  ( raw-delete-character )
  3114.            raw-delete-character
  3115.            if not(test-char "  ) ( "  ) fi
  3116.            set end-y -(end-y 1)
  3117.          )
  3118.         fi
  3119.         ;OCL{{{  go-line end-y
  3120.         set go-line-arg end-y
  3121.         go-line
  3122.         ;OCL}}}
  3123.         previous-line
  3124.         if test-text
  3125.          ;OCL{{{  combine lines
  3126.          ( next-line
  3127.            goto-counter end-x
  3128.            "$
  3129.            previous-line
  3130.            end-of-line
  3131.            while test-char "  ( delete-character )
  3132.            delete-character "  ;
  3133.          )
  3134.          ;OCL}}}
  3135.         fi
  3136.       )
  3137.       ;OCL}}}
  3138.      fi
  3139.      pretty-move-exit
  3140.    )
  3141. )
  3142. ;OCL{{{  undeclares
  3143. ( undeclare ( in-line in-mark splitt-put-line ) )
  3144. ;OCL}}}
  3145. ;OCL}}}
  3146. ;OCL{{{  handle-copy-op
  3147. ( deffun ( type ) handle-copy-op
  3148.    ( if >(type 0) ( select-no-highlight ) else ( mov-check-view ) fi
  3149.      screen-off
  3150.      set-end-mark
  3151.      ;OCL{{{  fold
  3152.      fold-region
  3153.      if folderr ( fold-error ) fi
  3154.      ;OCL}}}
  3155.      case
  3156.       ;OCL{{{  type=0 -> double region
  3157.       ( =(type 0)
  3158.          ( double-line
  3159.            unfold-fold
  3160.            previous-line
  3161.          )
  3162.       )
  3163.       ;OCL}}}
  3164.       ;OCL{{{  type>0 -> copy kill region
  3165.       ( >(type 0)
  3166.          ( enter-fold
  3167.            while not(test-bottom)
  3168.             ( copy-to-kill-buffer
  3169.               next-line
  3170.             )
  3171.            exit-fold
  3172.          )
  3173.       )
  3174.       ;OCL}}}
  3175.      default
  3176.       ;OCL{{{  change case
  3177.       ( enter-fold
  3178.         while not(test-bottom)
  3179.          ( goto 1
  3180.            while not(test-end-line)
  3181.             ( if
  3182.                 or
  3183.                  ( =(type -1)
  3184.                    and(=(type -2) test-char-set upper)
  3185.                    and(=(type -3) test-char-set lower)
  3186.                  )
  3187.                ( case-character-toggle )
  3188.               fi
  3189.               forward-character
  3190.             )
  3191.            next-line
  3192.            open-fold
  3193.          )
  3194.         exit-fold
  3195.       )
  3196.       ;OCL}}}
  3197.      esac
  3198.      unfold-fold
  3199.      ;OCL{{{  maybe combine splitted start
  3200.      if start-splitted ( combine-splitted-parts-start ) fi
  3201.      ;OCL}}}
  3202.      ;OCL{{{  maybe combine both splitted ends
  3203.      if end-splitted
  3204.       ;OCL{{{  combine both end-lines
  3205.       ( combine-splitted-parts-end
  3206.         if =(type 0)
  3207.          ;OCL{{{  double region, so two parts to combine!
  3208.          ( set end-y +(end-y -(end-y start-y))
  3209.            ;OCL{{{  go-line end-y
  3210.            set go-line-arg end-y
  3211.            go-line
  3212.            ;OCL}}}
  3213.            end-of-line
  3214.            set end-x store-pos
  3215.            combine-splitted-parts-end
  3216.          )
  3217.          ;OCL}}}
  3218.         fi
  3219.       )
  3220.       ;OCL}}}
  3221.      fi
  3222.      ;OCL}}}
  3223.      pretty-move-exit
  3224.    )
  3225. )
  3226. ;OCL}}}
  3227. ;OCL}}}
  3228. ;OCL{{{  kill-mark-region
  3229. ;OCL{{{  kill-all
  3230. ( deffun kill-all
  3231.    (
  3232.      ;OCL{{{  kill all lines
  3233.      enter-fold
  3234.      while not(test-bottom)
  3235.       ( kill-line )
  3236.      exit-fold
  3237.      ;OCL}}}
  3238.      unfold-fold
  3239.    )
  3240. )
  3241. ;OCL}}}
  3242. ( deffun kill-mark-region ( handle-fold-op-join(kill-all) ) )
  3243. ;OCL{{{  undeclares
  3244. ( undeclare ( kill-all ) )
  3245. ;OCL}}}
  3246. ;OCL}}}
  3247. ;OCL{{{  delete-mark-region
  3248. ( deffun delete-mark-region ( handle-fold-op-join(delete-line) ) )
  3249. ;OCL}}}
  3250. ;OCL{{{  toggle-case-mark-region
  3251. ( deffun toggle-case-mark-region ( handle-copy-op(-1) ) )
  3252. ;OCL}}}
  3253. ;OCL{{{  lowercase-mark-region
  3254. ( deffun lowercase-mark-region ( handle-copy-op(-2) ) )
  3255. ;OCL}}}
  3256. ;OCL{{{  uppercase-mark-region
  3257. ( deffun uppercase-mark-region ( handle-copy-op(-3) ) )
  3258. ;OCL}}}
  3259. ;OCL{{{  copy-mark-region
  3260. ( deffun copy-mark-region ( handle-copy-op(0) ) )
  3261. ;OCL}}}
  3262. ;OCL{{{  copy-kill-mark-region
  3263. ;OCL{{{  variables
  3264. ( defvar ( ckmr-x ckmr-l was-changed ) )
  3265. ;OCL}}}
  3266. ( deffun copy-kill-mark-region
  3267.    ( if was-view ( delete-mode-view ) fi
  3268.      ;OCL{{{  store change-status
  3269.      set was-changed counter test-file-changed
  3270.      ;OCL}}}
  3271.      ;OCL{{{  save position
  3272.      set ckmr-l cursor-level
  3273.      set go-line-arg store-line
  3274.      set ckmr-x store-pos
  3275.      ;OCL}}}
  3276.      local
  3277.       ( go-line-arg )
  3278.       ( handle-copy-op(1) )
  3279.      ;OCL{{{  restore-position
  3280.      screen-off
  3281.      go-line
  3282.      goto ckmr-x
  3283.      screen-on
  3284.      set-cursor-line ckmr-l
  3285.      ;OCL}}}
  3286.      ;OCL{{{  maybe set file unchanged again
  3287.      if not(was-changed)
  3288.       ( set-file-unchanged )
  3289.      fi
  3290.      ;OCL}}}
  3291.      if was-view ( add-mode-view ) fi
  3292.    )
  3293. )
  3294. ;OCL{{{  undeclares
  3295. ( undeclare ( ckmr-x ckmr-l was-changed ) )
  3296. ;OCL}}}
  3297. ;OCL}}}
  3298. ;OCL{{{  fold-mark-region
  3299. ( deffun fold-mark-region
  3300.    ( mov-check-view
  3301.      screen-off
  3302.      set-end-mark
  3303.      ;OCL{{{  create the fold
  3304.      if and(=(start-x end-x) =(start-y end-y))
  3305.       ( create-fold create-fold )
  3306.      else
  3307.       ( fold-region
  3308.         if folderr ( fold-error ) fi
  3309.       )
  3310.      fi
  3311.      ;OCL}}}
  3312.      pretty-move-exit
  3313.    )
  3314. )
  3315. ;OCL}}}
  3316. ;OCL{{{  undo-delete-line-unfolded-at-position
  3317. ( deffun undo-delete-line-unfolded-at-position
  3318.    ( in-at-position(undo-delete-line) )
  3319. )
  3320. ;OCL}}}
  3321. ;OCL{{{  unkill-unfolded-at-position
  3322. ( deffun unkill-unfolded-at-position
  3323.    ( in-at-position(insert-folded-kill-buffer) )
  3324. )
  3325. ;OCL}}}
  3326. ;OCL{{{  move-mark-region
  3327. ;OCL{{{  move-maybe-unfolded
  3328. ( deffun move-maybe-unfolded
  3329.    ( if =(start-y end-y) ( unfold-fold ) fi
  3330.      move-line
  3331.    )
  3332. )
  3333. ;OCL}}}
  3334. ;OCL{{{  move-fold-next
  3335. ( deffun move-fold-next
  3336.    ( move-line
  3337.      beginning-of-line
  3338.      create-fold
  3339.      next-line
  3340.      create-fold
  3341.      next-line
  3342.    )
  3343. )
  3344. ;OCL}}}
  3345. ( deffun move-mark-region
  3346.    ( if move-count
  3347.       ( in-at-position(move-fold-next) )
  3348.      else
  3349.       ( handle-fold-op-join(move-maybe-unfolded) )
  3350.      fi
  3351.    )
  3352. )
  3353. ;OCL{{{  undeclares
  3354. ( undeclare ( move-maybe-unfolded ) )
  3355. ;OCL}}}
  3356. ;OCL}}}
  3357. ;OCL{{{  indent-region macros
  3358. ( demand-load (
  3359.    ;OCL{{{  variables
  3360.    ( defvar ( irsx irsy irex irey ir-help ) )
  3361.    ;OCL}}}
  3362.    ;OCL{{{  indent-region-sub
  3363.    ( deffun ( width ) indent-region-sub
  3364.       ( mv-indent
  3365.         reset-user-mode MV
  3366.         set-user-mode SH
  3367.         if command
  3368.          ;OCL{{{  restore positions, maybe gen error on change
  3369.          ( set start-x irsx
  3370.            set start-y irsy
  3371.            set end-x irex
  3372.            set end-y irey
  3373.          )
  3374.          ;OCL}}}
  3375.         else
  3376.          ;OCL{{{  store positions
  3377.          ( mov-check-view
  3378.            set-end-mark
  3379.            set irsx start-x
  3380.            set irsy start-y
  3381.            set irex end-x
  3382.            set irey end-y
  3383.            if >(irey irsy)
  3384.             ( set irline start-line )
  3385.            else
  3386.             ( set irline end-line )
  3387.            fi
  3388.          )
  3389.          ;OCL}}}
  3390.         fi
  3391.         screen-off
  3392.         ;OCL{{{  pre handle highlight
  3393.         select-no-highlight
  3394.         ;OCL}}}
  3395.         ;OCL{{{  indent
  3396.         set folderr false
  3397.         indent-region( width )
  3398.         ;OCL}}}
  3399.         ;OCL{{{  post handle highlight
  3400.         set ir-help store-pos
  3401.         repeat screen-height
  3402.          ( next-line )
  3403.         if >(store-line end-y)
  3404.          ( set go-line-arg end-y
  3405.            go-line
  3406.          )
  3407.         fi
  3408.         next-line
  3409.         set modify-behaviour -1
  3410.         if highlight-off ( set modify-behaviour -4 ) fi
  3411.         create-fold
  3412.         set modify-behaviour 0
  3413.         go-start-mark
  3414.         goto ir-help
  3415.         ;OCL}}}
  3416.         screen-on
  3417.         set-cursor-line irline
  3418.         if folderr
  3419.          ( switch-to-edit-mode )
  3420.         else
  3421.          ( set command 1 )
  3422.         fi
  3423.       )
  3424.    )
  3425.    ;OCL}}}
  3426.    ;OCL{{{  shift-in-region
  3427.    ( deffun shift-in-region ( indent-region-sub( 1 ) ) )
  3428.    ;OCL}}}
  3429.    ;OCL{{{  shift-out-region
  3430.    ( deffun shift-out-region ( indent-region-sub( -1 ) ) )
  3431.    ;OCL}}}
  3432.    ;OCL{{{  shift-x-region
  3433.    ( deffun shift-x-region
  3434.       ( para
  3435.         prompt-counter cmd-in ( "shift-width-spaces "? "  )
  3436.         indent-region-sub( cmd-in )
  3437.       )
  3438.    )
  3439.    ;OCL}}}
  3440.    ;OCL{{{  shift-to-region
  3441.    ( deffun shift-to-region
  3442.       ( indent-region-sub( 0 )
  3443.         para
  3444.         prompt-counter cmd-in ( "shift-depth "? "  )
  3445.         indent-region-sub( -(cmd-in store-pos) )
  3446.       )
  3447.    )
  3448.    ;OCL}}}
  3449.    ;OCL{{{  undelcares
  3450.    ( undeclare ( irsx irsy irex irey ir-help ) )
  3451.    ;OCL}}}
  3452. ) )
  3453. ;OCL}}}
  3454. ;OCL{{{  switch-to-edit-mode-insert
  3455. ( deffun switch-to-edit-mode-insert
  3456.    ( set command 1
  3457.      switch-to-edit-mode
  3458.      delete-mode-overwrite
  3459.    )
  3460. )
  3461. ;OCL}}}
  3462. ;OCL{{{  switch-to-edit-mode-overwrite
  3463. ( deffun switch-to-edit-mode-overwrite
  3464.    ( set command 1
  3465.      switch-to-edit-mode
  3466.      add-mode-overwrite
  3467.    )
  3468. )
  3469. ;OCL}}}
  3470. ;OCL{{{  move-menu
  3471. ( deffun move-menu
  3472.    ( if not(in-prompt)
  3473.       ( begin-prompt-macro
  3474.         set cmd-in 1
  3475.         menu-counter cmd-in ( "Ok "  "Bindings "  "Help "  "Fold "  "Indent "  "Edit )
  3476.         end-prompt-macro
  3477.         case
  3478.          ( =(cmd-in 0) ( message ( ) ) )
  3479.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( describe-bindings ) )
  3480.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( mori-help ) )
  3481.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( fold-mark-region ) )
  3482.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( indent-region-sub( 0 ) ) )
  3483.          ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( set command 1 switch-to-edit-mode ) )
  3484.         default
  3485.          ( abort-macro )
  3486.         esac
  3487.       )
  3488.      fi
  3489.    )
  3490. )
  3491. ;OCL}}}
  3492. ;OCL{{{  undeclare's
  3493. ( undeclare
  3494.    ( edit-over
  3495.      select-no-highlight
  3496.      select-highlight
  3497.      handle-fold-op-join
  3498.      handle-copy-op
  3499.      indent-region-sub
  3500.    )
  3501. )
  3502. ;OCL}}}
  3503. ;OCL}}}
  3504. ;OCL{{{  buffer-move macs and mode string
  3505. ;OCL{{{  vars
  3506. ( defvar ( buff-arg ) )
  3507. ;OCL}}}
  3508. @lib buff-chg
  3509. @lib buff-size
  3510. ;OCL{{{  buffer-size-message
  3511. ( deffun buffer-size-message
  3512.    ( message
  3513.       (
  3514.         "[
  3515.         counter screen-height
  3516.         "x
  3517.         counter screen-width
  3518.         "]
  3519.       )
  3520.    )
  3521. )
  3522. ;OCL}}}
  3523. ;OCL{{{  buffer-op
  3524. ( deffun ( o ) buffer-op
  3525.    ( if >(buff-arg 1)
  3526.       ;OCL{{{  repeat action without screen
  3527.       ( screen-off
  3528.         do
  3529.          ( insert-ascii o
  3530.            set buff-arg -(buff-arg 1)
  3531.          )
  3532.         while >(buff-arg 0)
  3533.         screen-on
  3534.         redraw-display
  3535.       )
  3536.       ;OCL}}}
  3537.      else
  3538.       ;OCL{{{  do once
  3539.       ( insert-ascii o )
  3540.       ;OCL}}}
  3541.      fi
  3542.      buffer-size-message
  3543.    )
  3544. )
  3545. ;OCL}}}
  3546. ;OCL{{{  b-m-full-size-buffer
  3547. ( deffun b-m-full-size-buffer ( full-size-buffer buffer-size-message ) )
  3548. ;OCL}}}
  3549. ;OCL{{{  b-m-exit-buffer
  3550. ( deffun b-m-exit-buffer
  3551.    ( if >(used-buffers 1)
  3552.       ( exit-buffer
  3553.       )
  3554.      else
  3555.       ( switch-off-buffer-handling
  3556.         message ( M_NO_BUFFERS )
  3557.       )
  3558.      fi
  3559.    )
  3560. )
  3561. ;OCL}}}
  3562. ;OCL{{{  b-m-grow-buffer
  3563. ( deffun b-m-grow-buffer ( buffer-op(grow-buffer) ) )
  3564. ;OCL}}}
  3565. ;OCL{{{  b-m-shrink-buffer
  3566. ( deffun b-m-shrink-buffer ( buffer-op(shrink-buffer) ) )
  3567. ;OCL}}}
  3568. ;OCL{{{  b-m-widen-buffer
  3569. ( deffun b-m-widen-buffer ( buffer-op(widen-buffer) ) )
  3570. ;OCL}}}
  3571. ;OCL{{{  b-m-narrow-buffer
  3572. ( deffun b-m-narrow-buffer ( buffer-op(narrow-buffer) ) )
  3573. ;OCL}}}
  3574. ;OCL{{{  b-m-go-buffer
  3575. ( deffun b-m-go-buffer
  3576.    (
  3577.      ;OCL{{{  maybe prompt for number
  3578.      if <=(buff-arg 0)
  3579.       ( para
  3580.         prompt-counter buff-arg ( "buffernumber "  "? )
  3581.         buffer-move
  3582.       )
  3583.      fi
  3584.      ;OCL}}}
  3585.      ;OCL{{{  maybe switch buffer
  3586.      if and(>(buff-arg 0) <=(buff-arg used-buffers))
  3587.       ( goto-buffer-number buff-arg )
  3588.      fi
  3589.      ;OCL}}}
  3590.      message ()
  3591.    )
  3592. )
  3593. ;OCL}}}
  3594. ;OCL{{{  init-buff-arg
  3595. ( deffun ( x ) init-buff-arg
  3596.    ( if =(buff-arg -1)
  3597.       ( set buff-arg x )
  3598.      else
  3599.       ( set buff-arg +(*(10 buff-arg) x) )
  3600.      fi
  3601.      message ( M_ARG counter buff-arg )
  3602.    )
  3603. )
  3604. ;OCL}}}
  3605. ;OCL{{{  b-m-set-argument-0
  3606. ( deffun b-m-set-argument-0 ( init-buff-arg(0) ))
  3607. ;OCL}}}
  3608. ;OCL{{{  b-m-set-argument-1
  3609. ( deffun b-m-set-argument-1 ( init-buff-arg(1) ))
  3610. ;OCL}}}
  3611. ;OCL{{{  b-m-set-argument-2
  3612. ( deffun b-m-set-argument-2 ( init-buff-arg(2) ))
  3613. ;OCL}}}
  3614. ;OCL{{{  b-m-set-argument-3
  3615. ( deffun b-m-set-argument-3 ( init-buff-arg(3) ))
  3616. ;OCL}}}
  3617. ;OCL{{{  b-m-set-argument-4
  3618. ( deffun b-m-set-argument-4 ( init-buff-arg(4) ))
  3619. ;OCL}}}
  3620. ;OCL{{{  b-m-set-argument-5
  3621. ( deffun b-m-set-argument-5 ( init-buff-arg(5) ))
  3622. ;OCL}}}
  3623. ;OCL{{{  b-m-set-argument-6
  3624. ( deffun b-m-set-argument-6 ( init-buff-arg(6) ))
  3625. ;OCL}}}
  3626. ;OCL{{{  b-m-set-argument-7
  3627. ( deffun b-m-set-argument-7 ( init-buff-arg(7) ))
  3628. ;OCL}}}
  3629. ;OCL{{{  b-m-set-argument-8
  3630. ( deffun b-m-set-argument-8 ( init-buff-arg(8) ))
  3631. ;OCL}}}
  3632. ;OCL{{{  b-m-set-argument-9
  3633. ( deffun b-m-set-argument-9 ( init-buff-arg(9) ))
  3634. ;OCL}}}
  3635. ;OCL{{{  b-m-menu
  3636. ( deffun b-m-menu
  3637.    ( set cmd-in 1
  3638.      para
  3639.      ;OCL{{{  ask for commad type
  3640.      menu-counter
  3641.         cmd-in
  3642.       (    "Ok "- counter current-buffer-number
  3643.         "  "Size
  3644.         "  "Change
  3645.         "  "New
  3646.         "  "Quit
  3647.       )
  3648.      ;OCL}}}
  3649.      buffer-move
  3650.      case
  3651.       ;OCL{{{  ok
  3652.       ( =(cmd-in 0) ( switch-off-buffer-handling ) )
  3653.       ;OCL}}}
  3654.       ;OCL{{{  size
  3655.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  3656.          ( reset-user-mode BM
  3657.            set-user-mode BZ
  3658.            local
  3659.             ()
  3660.             ;OCL{{{  size-loop
  3661.             ( while 1
  3662.                (
  3663.                  ;OCL{{{  get command-code
  3664.                  set cmd-in 0
  3665.                  para
  3666.                  menu-counter
  3667.                     cmd-in
  3668.                   (    "Ok "- counter current-buffer-number
  3669.                        "[
  3670.                        counter screen-height
  3671.                        "cmd-in
  3672.                        counter screen-width
  3673.                        "]
  3674.                     "  "Grow
  3675.                     "  "Shrink
  3676.                     "  "Widen
  3677.                     "  "Narrow
  3678.                   )
  3679.                  buffer-move
  3680.                  ;OCL}}}
  3681.                  case
  3682.                   ( =(cmd-in 0) ( return-from-macro ) )
  3683.                   ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( grow-buffer ) )
  3684.                   ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( shrink-buffer ) )
  3685.                   ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( widen-buffer ) )
  3686.                   ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( narrow-buffer ) )
  3687.                  esac
  3688.                )
  3689.             )
  3690.             ;OCL}}}
  3691.            reset-user-mode BZ
  3692.            set-user-mode BM
  3693.            b-m-menu
  3694.          )
  3695.       )
  3696.       ;OCL}}}
  3697.       ;OCL{{{  change
  3698.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  3699.          ( reset-user-mode BM
  3700.            set-user-mode BC
  3701.            if >(used-buffers 1)
  3702.             ;OCL{{{  menu
  3703.             ( local
  3704.                ()
  3705.                ;OCL{{{  change-loop
  3706.                ( while 1
  3707.                   (
  3708.                     ;OCL{{{  get command-code
  3709.                     set cmd-in 0
  3710.                     para
  3711.                     ;OCL{{{  ask for command
  3712.                     menu-counter
  3713.                        cmd-in
  3714.                      (    "Ok "- counter current-buffer-number
  3715.                        "  "Up
  3716.                        "  "Down
  3717.                        "  "Left
  3718.                        "  "Right
  3719.                        "  "Previous
  3720.                        "  "Nexnt
  3721.                        "  "Select
  3722.                      )
  3723.                     ;OCL}}}
  3724.                     buffer-move
  3725.                     ;OCL}}}
  3726.                     case
  3727.                      ( =(cmd-in 0) ( return-from-macro ) )
  3728.                      ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( up-buffer ) )
  3729.                      ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( down-buffer ) )
  3730.                      ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( left-buffer ) )
  3731.                      ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( right-buffer ) )
  3732.                      ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( previous-buffer ) )
  3733.                      ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( next-buffer ) )
  3734.                      ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0) ( e-m-list-buffers return-from-macro ) )
  3735.                     esac
  3736.                   )
  3737.                )
  3738.                ;OCL}}}
  3739.             )
  3740.             ;OCL}}}
  3741.            else
  3742.             ;OCL{{{  message
  3743.             ( bell
  3744.               visible-bell
  3745.             )
  3746.             ;OCL}}}
  3747.            fi
  3748.            reset-user-mode BC
  3749.            set-user-mode BM
  3750.            b-m-menu
  3751.          )
  3752.       )
  3753.       ;OCL}}}
  3754.       ;OCL{{{  new
  3755.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  3756.          ( reset-user-mode BM
  3757.            set-user-mode BN
  3758.            ;OCL{{{  get command-code
  3759.            set cmd-in 0
  3760.            para
  3761.            menu-counter
  3762.               cmd-in
  3763.             (    "Ok "- counter current-buffer-number
  3764.               "  "Buffer
  3765.               "  "Adjacent-buffer
  3766.             )
  3767.            buffer-move
  3768.            ;OCL}}}
  3769.            reset-user-mode BN
  3770.            set-user-mode BM
  3771.            case
  3772.             ( =(cmd-in 0) ( ) )
  3773.             ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  3774.                ( switch-off-buffer-handling open-buffer return-from-macro )
  3775.             )
  3776.             ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  3777.                ( switch-off-buffer-handling open-adjacent-buffer return-from-macro )
  3778.             )
  3779.            esac
  3780.            b-m-menu
  3781.          )
  3782.       )
  3783.       ;OCL}}}
  3784.       ;OCL{{{  quit
  3785.       ( pre ( set cmd-in -(cmd-in 1) ) =(cmd-in 0)
  3786.          (
  3787.            ;OCL{{{  store file modified in string-buffer
  3788.            screen-off
  3789.            history-edit string-buffer ()
  3790.               insert-ascii M_CHANGED_LEAVE
  3791.               newline-and-indent
  3792.            screen-on
  3793.            ;OCL}}}
  3794.            b-m-exit-buffer
  3795.            if in-prompt ( yes-no-menu(true) ) fi
  3796.            if buffer-moving
  3797.             ( b-m-menu )
  3798.            fi
  3799.          )
  3800.       )
  3801.       ;OCL}}}
  3802.      default
  3803.       ( abort-macro )
  3804.      esac
  3805.    )
  3806. )
  3807. ;OCL}}}
  3808. ;OCL{{{  undeclares
  3809. ( undeclare ( init-buff-arg ) )
  3810. ;OCL}}}
  3811. ;OCL}}}
  3812. ;OCL{{{  switches
  3813. ;OCL{{{  switch-on-buffer-handling
  3814. ( deffun switch-on-buffer-handling
  3815.    ( set buffer-moving 1
  3816.      set buff-arg -1
  3817.      reset-user-mode ED
  3818.      set-user-mode BM
  3819.      buffer-move
  3820.    )
  3821. )
  3822. ;OCL}}}
  3823. ;OCL{{{  switch-off-buffer-handling
  3824. ( deffun switch-off-buffer-handling
  3825.    ( set-user-mode ED
  3826.      reset-user-mode BM
  3827.      edit
  3828.      set buffer-moving 0
  3829.    )
  3830. )
  3831. ;OCL}}}
  3832. ;OCL{{{  switch-to-move-mode
  3833. ( deffun switch-to-move-mode
  3834.    ( if in-prompt ( return-from-macro ) fi
  3835.      reset-user-mode ED
  3836.      set-user-mode MV
  3837.      delay-auto-save
  3838.      set-start-mark
  3839.      set-end-mark
  3840.      moves
  3841.      set moving 1
  3842.      store-move-modes
  3843.      status-line-on
  3844.      set command 0
  3845.      set irline 0
  3846.    )
  3847. )
  3848. ;OCL}}}
  3849. ;OCL{{{  switch-to-edit-mode
  3850. ( deffun switch-to-edit-mode
  3851.    ( if in-prompt ( return-from-macro ) fi
  3852.      clear-marks
  3853.      reset-user-mode MV
  3854.      reset-user-mode BM
  3855.      reset-user-mode SH
  3856.      set-user-mode ED
  3857.      edit
  3858.      ;OCL{{{  reset move-mode
  3859.      if moving
  3860.       ( set moving 0
  3861.         flush-auto-save
  3862.       )
  3863.      fi
  3864.      ;OCL}}}
  3865.      restore-move-modes
  3866.      ;OCL{{{  maybe bell (exit without correct ended command)
  3867.      if and(=(command 0) <>(startup 0)) ( bell visible-bell ) fi
  3868.      ;OCL}}}
  3869.      ;OCL{{{  maybe switch statusline off
  3870.      if =(status-line 0) ( status-line-off ) fi
  3871.      ;OCL}}}
  3872.      ;OCL{{{  maybe redraw
  3873.      if <>(command 0) ( redraw-display ) fi
  3874.      ;OCL}}}
  3875.      set irline 0
  3876.    )
  3877. )
  3878. ;OCL}}}
  3879. ;OCL}}}
  3880. ;OCL{{{  modes
  3881. @lib autolang
  3882. ;OCL{{{  statusline
  3883. ( defvar ( really-no-stat ) )
  3884. ;OCL{{{  check-status-line
  3885. ( defmac check-status-line
  3886.    ( if and(not(really-no-stat) >(used-buffers 1))
  3887.       ( switch-status-line-on )
  3888.      fi
  3889.    )
  3890. )
  3891. ;OCL}}}
  3892. ;OCL{{{  switch-status-line-off
  3893. ( deffun switch-status-line-off
  3894.    ( case
  3895.       ( in-prompt ( ) )
  3896.      default
  3897.       ( set status-line false
  3898.         status-line-off
  3899.         if >(used-buffers 1) ( set really-no-stat 1 ) fi
  3900.       )
  3901.      esac
  3902.    )
  3903. )
  3904. ;OCL}}}
  3905. ;OCL{{{  switch-status-line-on
  3906. ( deffun switch-status-line-on
  3907.    ( case
  3908.       ( in-prompt ( ) )
  3909.      default
  3910.       ( set status-line true
  3911.         status-line-on
  3912.       )
  3913.      esac
  3914.    )
  3915. )
  3916. ;OCL}}}
  3917. ( undeclare ( really-no-stat ) )
  3918. ;OCL}}}
  3919. ;OCL{{{  add-mode-extended
  3920. @if-using (L-EXT)
  3921.    ( deffun add-mode-extended
  3922.       ( set extended-version 1
  3923.         reset-user-mode NOEX
  3924.         @if-using (L-EXT)
  3925.            set-user-mode LEXT
  3926.         @fi
  3927.       )
  3928.    )
  3929. @fi
  3930. @if-using not(L-EXT)
  3931.    ( defmac add-mode-extended ( delete-mode-extended ) )
  3932. @fi
  3933. ;OCL}}}
  3934. ;OCL{{{  delete-mode-extended
  3935. ( deffun delete-mode-extended
  3936.    ( set extended-version -1
  3937.      reset-user-mode NOEX
  3938.      @if-using (L-EXT)
  3939.         reset-user-mode LEXT
  3940.      @fi
  3941.    )
  3942. )
  3943. ;OCL}}}
  3944. ;OCL{{{  set-mode-raw
  3945. ( deffun set-mode-raw
  3946.    ( switch-to-edit-mode
  3947.      set extended-version 0
  3948.      set-user-mode NOEX
  3949.      @if-using (L-EXT)
  3950.         reset-user-mode LEXT
  3951.      @fi
  3952.    )
  3953. )
  3954. ;OCL}}}
  3955. ;OCL{{{  mori-add-mode-full-shift
  3956. ( deffun mori-add-mode-full-shift
  3957.    ( set full-shifting 1
  3958.      add-mode-full-shift
  3959.    )
  3960. )
  3961. ;OCL}}}
  3962. ;OCL{{{  mori-delete-mode-full-shift
  3963. ( deffun mori-delete-mode-full-shift
  3964.    ( set full-shifting 0
  3965.      delete-mode-full-shift
  3966.    )
  3967. )
  3968. ;OCL}}}
  3969. ;OCL}}}
  3970. ;OCL{{{  hooks
  3971. ;OCL{{{  buff-init-state
  3972. ( deffun buff-init-state
  3973.    ( @if-using (L-EXT)
  3974.         ;OCL{{{  maybe switch on wrap
  3975.         touch-char-sets
  3976.         if or(test-language Roff test-language TeX)
  3977.          ( add-mode-wrap )
  3978.         else
  3979.          ( delete-mode-wrap )
  3980.         fi
  3981.         ;OCL}}}
  3982.      @fi
  3983.    )
  3984. )
  3985. ;OCL}}}
  3986. ;OCL{{{  change-buffer-macro-exe
  3987. ( deffun change-buffer-macro-exe
  3988.    ( @if-using ( ALIEN-HOOKS )
  3989.         if eval ( alien-change-buffer-macro ) ( return-from-macro ) fi
  3990.      @fi
  3991.      @if-using ( SHELL-MODE )
  3992.         if shell-mode-active
  3993.          ( return-from-macro )
  3994.         fi
  3995.      @fi
  3996.      check-status-line
  3997.      set buff-arg -1
  3998.      buff-init-state
  3999.    )
  4000. )
  4001. ;OCL}}}
  4002. ;OCL{{{  read-newfile-macro-exe
  4003. ;OCL{{{  variables
  4004. ( defvar ( size-h size-w start-ocl x rec-rnf-mac ) )
  4005. ;OCL}}}
  4006. ;OCL{{{  startup macros
  4007. ( demand-load
  4008.    (
  4009.      ;OCL{{{  startup1
  4010.      ( deffun startup-1
  4011.         ( screen-off
  4012.           ;OCL{{{  init fill column with 79
  4013.           set modify-behaviour 79
  4014.           set-fill-column
  4015.           set modify-behaviour 0
  4016.           ;OCL}}}
  4017.           ;OCL{{{  prepare internal mode handling
  4018.           ;OCL{{{  statusline
  4019.           set status-line true
  4020.           ;OCL}}}
  4021.           ;OCL{{{  extended mode
  4022.           set extended-version 1
  4023.           ;OCL}}}
  4024.           set-user-mode ED
  4025.           add-mode-auto-indent
  4026.           add-mode-auto-language
  4027.           ;OCL}}}
  4028.           ;OCL{{{  get environment variables
  4029.           ;OCL{{{  EDT used?
  4030.           @if-using ( SUNEDT )
  4031.              if test-term "SUNEDT
  4032.               ( set EDT-used 1 )
  4033.              else
  4034.               ;OCL{{{  check ORIGAMITERM
  4035.               ( history-edit misc ()
  4036.                    getenv "ORIGAMITERM
  4037.                    if
  4038.                     ;OCL{{{  ==SUNEDT
  4039.                       and
  4040.                        ( pre
  4041.                           ( backward-character
  4042.                             backward-character
  4043.                             backward-character
  4044.                             backward-character
  4045.                             backward-character
  4046.                             backward-character
  4047.                           )
  4048.                          test-str "SUNEDT
  4049.                          test-begin-line
  4050.                        )
  4051.                     ;OCL}}}
  4052.                     ( set EDT-used 1 )
  4053.                    fi
  4054.                   newline-and-indent
  4055.               )
  4056.               ;OCL}}}
  4057.              fi
  4058.              if EDT-used
  4059.               ( set-user-mode EDT-TAG )
  4060.              fi
  4061.           @fi
  4062.           ;OCL}}}
  4063.           ;OCL{{{  get MAKE_CMD
  4064.           history-edit make-cmd-hist ()
  4065.              get-make-cmd-var
  4066.              if test-begin-line
  4067.               ( make-cmd-def )
  4068.              fi
  4069.              newline-and-indent
  4070.           ;OCL}}}
  4071.           ;OCL{{{  get SPELL_CMD
  4072.           history-edit spell-command ()
  4073.              get-spell-cmd-var
  4074.              if test-begin-line
  4075.               ( default-spell-command )
  4076.              fi
  4077.              newline-and-indent
  4078.           ;OCL}}}
  4079.           ;OCL{{{  get MAIL_CMD
  4080.           history-edit mail-cmd-hist ()
  4081.              get-mail-cmd-var
  4082.              if test-begin-line
  4083.               ( mail-cmd-def )
  4084.              fi
  4085.              newline-and-indent
  4086.           ;OCL}}}
  4087.           @if-using ( SHELL-MODE )
  4088.              I-startup-read
  4089.           @fi
  4090.           ;OCL}}}
  4091.           ;OCL{{{  handle ocl-argument
  4092.           ;OCL{{{  tags-file
  4093.           history-edit tags-file ()
  4094.           if ocl-arg-field(2)
  4095.            ( set tags-user-tags-file true
  4096.              get-history argument-list -(ocl-arg-field(1) ocl-arg-field(2))
  4097.            )
  4098.           else
  4099.            ( "default )
  4100.           fi
  4101.           newline-and-indent
  4102.           ;OCL}}}
  4103.           ;OCL{{{  spell-command
  4104.           history-edit spell-command ()
  4105.           get-history argument-list -(ocl-arg-field(1) ocl-arg-field(4))
  4106.           newline-and-indent
  4107.           ;OCL}}}
  4108.           ;OCL{{{  make
  4109.           history-edit make-cmd-hist ()
  4110.           get-history argument-list -(ocl-arg-field(1) ocl-arg-field(5))
  4111.           newline-and-indent
  4112.           ;OCL}}}
  4113.           ;OCL{{{  mail
  4114.           history-edit mail-cmd-hist ()
  4115.           get-history argument-list -(ocl-arg-field(1) ocl-arg-field(6))
  4116.           newline-and-indent
  4117.           ;OCL}}}
  4118.           @if-using ( SHELL-MODE )
  4119.              ;OCL{{{  nn
  4120.              history-edit I-nn-cmd ()
  4121.              get-history argument-list -(ocl-arg-field(1) ocl-arg-field(7))
  4122.              newline-and-indent
  4123.              ;OCL}}}
  4124.           @fi
  4125.           ;OCL{{{  match filter
  4126.           history-edit match ()
  4127.           previous-line
  4128.           if test-begin-line ( ". ) fi
  4129.           newline-and-indent
  4130.           ;OCL}}}
  4131.           ;OCL{{{  no-match filter
  4132.           history-edit no-match ()
  4133.           previous-line
  4134.           if test-begin-line ( insert-ascii path-separator ) fi
  4135.           newline-and-indent
  4136.           ;OCL}}}
  4137.           set start-ocl ocl-argument
  4138.           do
  4139.            (
  4140.              ;OCL{{{  init ocl-argument value
  4141.              set cmd-in 0
  4142.              if <>(ocl-argument -1)
  4143.               ( set cmd-in ocl-argument )
  4144.              fi
  4145.              ;OCL}}}
  4146.              ;OCL{{{  handle bit 8192, 1=lond-diredit off
  4147.              if >=(cmd-in 8192)
  4148.               ( set cmd-in -(cmd-in 8192) )
  4149.              else
  4150.               ( set diredit-long 1 )
  4151.              fi
  4152.              ;OCL}}}
  4153.              ;OCL{{{  handle bit 4096, 1=center on
  4154.              if >=(cmd-in 4096)
  4155.               ( set cmd-in -(cmd-in 4096)
  4156.                 add-mode-center
  4157.               )
  4158.              fi
  4159.              ;OCL}}}
  4160.              ;OCL{{{  handle bit 2048, 1=time off
  4161.              if >=(cmd-in 2048)
  4162.               ( set cmd-in -(cmd-in 2048) )
  4163.              else
  4164.               ( add-mode-time )
  4165.              fi
  4166.              ;OCL}}}
  4167.              ;OCL{{{  handle bit 1024, 1=no-overstrike
  4168.              if >=(cmd-in 1024)
  4169.               ( no-overstrike
  4170.                 set cmd-in -(cmd-in 1024)
  4171.               )
  4172.              fi
  4173.              ;OCL}}}
  4174.              ;OCL{{{  handle bit 512, 0=auto-langage on
  4175.              if >=(cmd-in 512)
  4176.               ( delete-mode-auto-language
  4177.                 set cmd-in -(cmd-in 512)
  4178.               )
  4179.              else
  4180.               ( add-mode-auto-language )
  4181.              fi
  4182.              ;OCL}}}
  4183.              ;OCL{{{  handle bit 256, 0=full-shift on
  4184.              if >=(cmd-in 256)
  4185.               ( mori-delete-mode-full-shift
  4186.                 set cmd-in -(cmd-in 256)
  4187.               )
  4188.              else
  4189.               ( mori-add-mode-full-shift )
  4190.              fi
  4191.              ;OCL}}}
  4192.              ;OCL{{{  handle bit 128, 0=autoindent on
  4193.              if >=(cmd-in 128)
  4194.               ( delete-mode-auto-indent
  4195.                 set cmd-in -(cmd-in 128)
  4196.               )
  4197.              else
  4198.               ( add-mode-auto-indent )
  4199.              fi
  4200.              ;OCL}}}
  4201.              ;OCL{{{  handle bits 64/32, 0=xmagic
  4202.              case
  4203.               ( >=(cmd-in 96) ( delete-mode-regular-expression set cmd-in -(cmd-in 96) ) )
  4204.               ( >=(cmd-in 64) ( add-mode-basic-regular-expression set cmd-in -(cmd-in 64) ) )
  4205.               ( >=(cmd-in 32) ( add-mode-basic-regular-expression set cmd-in -(cmd-in 32) ) )
  4206.              default
  4207.               ( add-mode-extended-regular-expression )
  4208.              esac
  4209.              ;OCL}}}
  4210.              ;OCL{{{  handle bit 16, 0=highlight on
  4211.              if >=(cmd-in 16)
  4212.               ( delete-mode-highlight
  4213.                 set cmd-in -(cmd-in 16)
  4214.               )
  4215.              else
  4216.               ( add-mode-highlight )
  4217.              fi
  4218.              ;OCL}}}
  4219.              ;OCL{{{  handle bit 8, 0=position on
  4220.              if >=(cmd-in 8)
  4221.               ( delete-mode-position
  4222.                 set cmd-in -(cmd-in 8)
  4223.               )
  4224.              else
  4225.               ( add-mode-position )
  4226.              fi
  4227.              ;OCL}}}
  4228.              ;OCL{{{  handle bit 4, 0=buff-save off
  4229.              if >=(cmd-in 4)
  4230.               ( set cmd-in -(cmd-in 4)
  4231.                 add-mode-buffer-save
  4232.               )
  4233.              else
  4234.               ( delete-mode-buffer-save )
  4235.              fi
  4236.              ;OCL}}}
  4237.              ;OCL{{{  handle bit 2, 0=extended
  4238.              if >=(cmd-in 2)
  4239.               ( set cmd-in -(cmd-in 2)
  4240.                 delete-mode-extended
  4241.               )
  4242.              else
  4243.               ( add-mode-extended )
  4244.              fi
  4245.              ;OCL}}}
  4246.              ;OCL{{{  handle bit 1, 0=statusline on
  4247.              if >(cmd-in 0)
  4248.               ( set cmd-in -(cmd-in 1)
  4249.                 switch-status-line-off
  4250.               )
  4251.              else
  4252.               ( switch-status-line-on )
  4253.              fi
  4254.              ;OCL}}}
  4255.              ;OCL{{{  check, if valid value given
  4256.              if <>(cmd-in 0)
  4257.               ( set ocl-argument -1
  4258.                 set startup -1
  4259.               )
  4260.              else
  4261.               ( set ocl-argument 0 )
  4262.              fi
  4263.              ;OCL}}}
  4264.            )
  4265.           while <>(ocl-argument 0)
  4266.           ;OCL}}}
  4267.           ;OCL{{{  maybe redraw, window size changed?
  4268.           set size-h screen-height
  4269.           set size-w screen-width
  4270.           set modify-behaviour 1
  4271.           center-and-redraw-display
  4272.           set modify-behaviour 0
  4273.           if or(<>(size-h screen-height) <>(size-w screen-width))
  4274.            ( center-and-redraw-display )
  4275.           fi
  4276.           screen-on
  4277.           ;OCL}}}
  4278.           screen-on
  4279.         )
  4280.      )
  4281.      ;OCL}}}
  4282.      ;OCL{{{  startup2
  4283.      ( deffun startup-2
  4284.         ( load-function not( startup-1 )
  4285.           ;OCL{{{  go tag/start shell or show startup message
  4286.           if =(startup 0)
  4287.            ( set startup 1
  4288.              @if-using ( SHELL-MODE )
  4289.                 if ocl-arg-field(15)
  4290.                  ;OCL{{{  start as shell
  4291.                  ( begin-shell-mode
  4292.                    I-startup
  4293.                    exit
  4294.                  )
  4295.                  ;OCL}}}
  4296.                 fi
  4297.              @fi
  4298.              ;OCL{{{  gotags
  4299.              if >(ocl-arg-field(3) 0)
  4300.               ( screen-off
  4301.                 history-edit search ()
  4302.                 get-history argument-list -(ocl-arg-field(3) 1)
  4303.                 newline-and-indent
  4304.                 screen-on
  4305.                 set ocl-arg-field(3) -1
  4306.                 go-tag-mark(false true true)
  4307.                 set ocl-arg-field(3) 0
  4308.               )
  4309.              fi
  4310.              ;OCL}}}
  4311.              case
  4312.               ( tags-error ( tags-complain exit ) )
  4313.              default
  4314.               ( if and(diredit-long =(file-type 1))
  4315.                  ( message ( "[ "long  "  "directory "  "data! "] )
  4316.                    screen-off
  4317.                    set rec-rnf-mac true
  4318.                    set modify-behaviour +(file-number 1)
  4319.                    read-list-file
  4320.                    set modify-behaviour 0
  4321.                    screen-on
  4322.                    redraw-display
  4323.                  )
  4324.                 fi
  4325.                 message-exit ( "[ "Have "  "a "  "nice "  "day! "] )
  4326.               )
  4327.              esac
  4328.            )
  4329.           else
  4330.            ( set startup 1
  4331.              message-exit ( "[ "invalid "  "ocl-init "  counter start-ocl ", "  "using "  "default=0! "] )
  4332.            )
  4333.           fi
  4334.           ;OCL}}}
  4335.         )
  4336.      )
  4337.      ;OCL}}}
  4338.    )
  4339. )
  4340. ;OCL}}}
  4341.  
  4342. ( deffun read-newfile-macro-exe
  4343.    ( if not(rec-rnf-mac)
  4344.       ( @if-using ( ALIEN-HOOKS )
  4345.            if eval ( alien-read-newfile-macro ) ( return-from-macro ) fi
  4346.         @fi
  4347.         ;OCL{{{  startup-stuff
  4348.         if =(startup 0) ( startup-1 ) fi
  4349.         ;OCL}}}
  4350.         @if-using ( SHELL-MODE )
  4351.            if shell-mode-active
  4352.             ( return-from-macro )
  4353.            fi
  4354.         @fi
  4355.         buff-init-state
  4356.         @if-using ( ADD-NEWFILE )
  4357.            add-new-file
  4358.         @fi
  4359.         ;OCL{{{  maybe edit mode, no command check
  4360.         if and(=(buffer-moving 0) not(moving))
  4361.          ( set command 1
  4362.            switch-to-edit-mode
  4363.          )
  4364.         fi
  4365.         ;OCL}}}
  4366.         ;OCL{{{  maybe change file at startup
  4367.         if not(no-auto-change)
  4368.          ( set-auto-language
  4369.            ;OCL{{{  maybe empty-file to one-line-file
  4370.            if and(=(file-type 0) test-bottom =(1 store-line))
  4371.             ( screen-off
  4372.               beginning-of-line
  4373.               newline-and-indent
  4374.               set-file-unchanged
  4375.               previous-line
  4376.               screen-on
  4377.               redraw-display
  4378.             )
  4379.            fi
  4380.            ;OCL}}}
  4381.          )
  4382.         fi
  4383.         ;OCL}}}
  4384.         ;OCL{{{  startup stuff
  4385.         if <=(startup 0) ( startup-2 ) fi
  4386.         ;OCL}}}
  4387.         message ( history error-list )
  4388.       )
  4389.      fi
  4390.      set rec-rnf-mac false
  4391.    )
  4392. )
  4393. ;OCL{{{  undeclare startup macros and variables
  4394. ( undeclare ( size-h size-w startup-1 startup-2 startup start-ocl x rec-rnf-mac ) )
  4395. ;OCL}}}
  4396. ;OCL}}}
  4397. ;OCL{{{  knb-macro
  4398. ( deffun knb-macro
  4399.    ( @if-using ( ALIEN-HOOKS )
  4400.         if eval ( alien-key-not-bound-macro ) ( return-from-macro ) fi
  4401.      @fi
  4402.      @if-using ( SHELL-MODE )
  4403.         if shell-mode-active
  4404.          ( I-key-not-bound
  4405.            return-from-macro
  4406.          )
  4407.         fi
  4408.      @fi
  4409.      set buff-arg -1
  4410.      if not(in-prompt)
  4411.       ( message ( M_NOT_BOUND )
  4412.         if =(0 buffer-moving) ( abort-hook ) fi
  4413.       )
  4414.      fi
  4415.    )
  4416. )
  4417. ;OCL}}}
  4418. ;OCL{{{  v-macro
  4419. ( deffun v-macro
  4420.    ( @if-using ( ALIEN-HOOKS )
  4421.         if eval ( alien-view-macro ) ( return-from-macro ) fi
  4422.      @fi
  4423.      @if-using ( SHELL-MODE )
  4424.         if shell-mode-active
  4425.          ( I-view-macro
  4426.            return-from-macro
  4427.          )
  4428.         fi
  4429.      @fi
  4430.      if and(=(moving 0) =(buffer-moving 0))
  4431.       ( message ( M_VIEW ) abort-macro )
  4432.      else
  4433.       ( knb-macro )
  4434.      fi
  4435.    )
  4436. )
  4437. ;OCL}}}
  4438. ;OCL{{{  abort-hook
  4439. ( forward lib-abort-hooks )
  4440. ( deffun abort-hook
  4441.    ( @if-using ( ALIEN-HOOKS )
  4442.         if eval ( alien-abort-macro ) ( return-from-macro ) fi
  4443.      @fi
  4444.      @if-using ( SHELL-MODE )
  4445.         if shell-mode-active
  4446.          ( I-abort-hook
  4447.            return-from-macro
  4448.          )
  4449.         fi
  4450.      @fi
  4451.      ;OCL{{{  cmd-in=1, if abort
  4452.      case
  4453.       ( last-message M_ABORTED ( set cmd-in 1 ))
  4454.       ( and(last-message M_VIEW =(moving 0))
  4455.          ( set cmd-in -1)
  4456.       )
  4457.      default
  4458.       ( set cmd-in 0 )
  4459.      esac
  4460.      ;OCL}}}
  4461.      lib-abort-hooks
  4462.      set no-auto-change false
  4463.      set modify-behaviour 0
  4464.      set prompting false
  4465.      reset-user-mode FM
  4466.      reset-user-mode TM
  4467.      reset-user-mode PM
  4468.      reset-user-mode BC
  4469.      reset-user-mode BM
  4470.      reset-user-mode BN
  4471.      reset-user-mode BZ
  4472.      ;OCL{{{  full-shift
  4473.      if full-shifting ( add-mode-full-shift ) else ( delete-mode-full-shift ) fi
  4474.      ;OCL}}}
  4475.      case
  4476.       ( <>(buffer-moving 0) ( switch-off-buffer-handling redraw-display ) )
  4477.       ( =(moving 0) ( redraw-display edit ) )
  4478.      default
  4479.       ( switch-to-edit-mode )
  4480.      esac
  4481.      restore-auto-save
  4482.      case
  4483.       ( >(cmd-in 0) ( message-exit ( M_ABORTED )))
  4484.       ( =(cmd-in 0) ( message-exit ( M_NOT_BOUND )))
  4485.      default
  4486.       ( message-exit ( M_VIEW ))
  4487.      esac
  4488.    )
  4489. )
  4490. ;OCL}}}
  4491. ;OCL{{{  begin-prompt
  4492. ( deffun begin-prompt
  4493.    ( case
  4494.       @if-using ( ALIEN-HOOKS )
  4495.          ( eval ( alien-begin-prompt-macro ) ( ) )
  4496.       @fi
  4497.       @if-using ( SHELL-MODE )
  4498.          ( shell-mode-active ( I-prompt-in ) )
  4499.       @fi
  4500.       ( moving ( para ) )
  4501.       ( buffer-moving ( para ) )
  4502.      default
  4503.       ( if prompting ( para ) fi )
  4504.      esac
  4505.    )
  4506. )
  4507. ;OCL}}}
  4508. ;OCL{{{  end-prompt
  4509. ( deffun end-prompt
  4510.    ( case
  4511.       @if-using ( ALIEN-HOOKS )
  4512.          ( eval ( alien-end-prompt-macro ) ( ) )
  4513.       @fi
  4514.       @if-using ( SHELL-MODE )
  4515.          ( shell-mode-active ( I-prompt-out ) )
  4516.       @fi
  4517.       ( moving ( moves ) )
  4518.       ( buffer-moving ( buffer-move ) )
  4519.      default
  4520.       ( edit )
  4521.      esac
  4522.    )
  4523. )
  4524. ;OCL}}}
  4525. ;OCL}}}
  4526. ;OCL{{{  redefine save/exits for buffer-save
  4527. ;OCL{{{  e-m-save-file
  4528. ( defmac e-m-save-file- ( e-m-save-file ) )
  4529. ( undeclare ( e-m-save-file ) )
  4530. ( deffun e-m-save-file
  4531.    ( if and(not(in-prompt) buff-saving) ( mori-dump-buffers-to-file ) fi
  4532.      e-m-save-file-
  4533.    )
  4534. )
  4535. ( undeclare ( e-m-save-file- ) )
  4536. ;OCL}}}
  4537. ;OCL{{{  exit-buffer
  4538. ( defmac exit-buffer- ( exit-buffer ) )
  4539. ( undeclare ( exit-buffer ) )
  4540. ( @if-using ( SHELL-MODE ) defmac @fi
  4541.   @if-using not( SHELL-MODE ) deffun @fi
  4542.      exit-buffer
  4543.    ( if and(not(in-prompt) buff-saving) ( mori-dump-buffers-to-file ) fi
  4544.      exit-buffer-
  4545.    )
  4546. )
  4547. ( undeclare ( exit-buffer- ) )
  4548. ;OCL}}}
  4549. ;OCL{{{  exit-origami
  4550. ( defmac exit-origami- ( exit-origami ) )
  4551. ( undeclare ( exit-origami ) )
  4552. ( @if-using ( SHELL-MODE ) defmac @fi
  4553.   @if-using not( SHELL-MODE ) deffun @fi
  4554.      exit-origami
  4555.    ( if and(not(in-prompt) buff-saving) ( mori-dump-buffers-to-file ) fi
  4556.      exit-origami-
  4557.    )
  4558. )
  4559. ( undeclare ( exit-origami- ) )
  4560. ;OCL}}}
  4561. ;OCL{{{  save-and-exit-buffer
  4562. ( defmac save-and-exit-buffer- ( save-and-exit-buffer ) )
  4563. ( undeclare ( save-and-exit-buffer ) )
  4564. ( @if-using ( SHELL-MODE ) defmac @fi
  4565.   @if-using not( SHELL-MODE ) deffun @fi
  4566.      save-and-exit-buffer
  4567.    ( if and(not(in-prompt) buff-saving) ( mori-dump-buffers-to-file ) fi
  4568.      save-and-exit-buffer-
  4569.    )
  4570. )
  4571. ( undeclare ( save-and-exit-buffer- ) )
  4572. ;OCL}}}
  4573. ;OCL}}}
  4574.